29
Jul

Use perldoc to View Perl Manual/Documentation

Simply put, perldoc is the man page of perl applications. Use it and use it often when dealing with perl utilities. For example:

perldoc open

Reveals…

System::Library::Perl:User.Contributed PeSystem::Library::Perl::5.8.8::open(3)

NAME
       open − perl pragma to set default PerlIO layers for input and output

SYNOPSIS
           use open IN  => ":crlf", OUT => ":bytes";
           use open OUT => ’:utf8’;
           use open IO  => ":encoding(iso−8859−7)";

           use open IO  => ’:locale’;

           use open ’:utf8’;
           use open ’:locale’;
           use open ’:encoding(iso−8859−7)’;

           use open ’:std’;

DESCRIPTION
       Full‐fledged support for I/O layers is now implemented provided Perl is
       configured to use PerlIO as its IO system (which is now the default).
       ...
       ...

28
Jul

Get Weather Report from Terminal

I’ve been on a kick recently about doing everything in the terminal and I became excited about the possibility of doing it through the terminal. I was excited until my little research on the subject revealed that this horse has been beaten left and right and up and down and diagonally. There were so many different ways of doing it, I sorta lost the urge to create a post about it. Well, here I am anyways listing the ones I found to be the most interesting. Check ‘em out if you’re interested…

http://fungi.yuggoth.org/weather/
http://linuxshellaccount.blogspot.com/2008/09/bash-script-to-get-weather-forecasts.html

telnet rainmaker.wunderground.com
curl http://weather.noaa.gov/pub/data/forecasts/city/state/city.txt

27
Jul

Troubleshooting Network Connection with ‘tcpdump’ and ‘arp’

A quick and easy way to troubleshoot network connections in an embedded Linux environment is to use the ping, tcpdump, and arp commands. This will allow you to see what might be happening with the traffic on your network at the packet level. Once scenario would be that you’re not getting a successful ping between two computers on the network. All reason tells you that it should be working, but maybe there’s something wrong at the driver level? To start troubleshooting, fire up tcpdump on the box being pinged (ip: 192.168.1.100) and specify the network interface and IP address of the machine doing the pinging (ip: 192.168.1.101):

tcpdump -i eth0 host 192.168.1.101

Now, run the ping test:

ping 192.168.1.100

At this point, if you get an output from tcpdump, you’ll know that the packet has made its way to the target machine (192.168.1.100). The next step would be to see if you ever received an acknowledgment from the target machine. Run arp on the machine doing the pinging (192.168.1.101):

arp -an

If you see something like ? (192.168.1.112) at (incomplete) on en1 [ethernet], that means you never got an acknowledgment back from the target machine (192.168.1.100).

At this point in this scenario, we would start to dive into what could be wrong. In this particular situation, it was a driver issue with assigning a MAC address to the interface.

This is just one scenario to get you familiar with how to use tcpdump and arp and gather information about the networking issue. Please refer to the utility man pages for more information.

26
Jul

Tools Worth a Gander: expect and pexpect

For those of you interested in programming a dialogue (simulating user actions) for an interactive program take a look at expect (pexpect if you’re into python). The tools are useful if you’re in an environment that needs a lot of test automation. Here’s an article that goes into a bit more detail:
http://www.noah.org/wiki/Pexpect#Description_of_Pexpect

15
Jul

View Configuration File Used to Build Currently Running Kernel

If enabled as an option in the pre-compiled kernel configuration, the file /proc/config.gz can inform you of what options your currently running kernel was compiled with. The writers over at Linux Insight have gone into a bit more detail about doing this. You can read up on it here:
http://www.linuxinsight.com/proc_config.gz.html

30
Jun

A Great Countdown Script Example

Somebody over at the linuxconfig.org website posted a really good countdown script that I’d like to share with you. Specify a date and time and the script will start and display the countdown. Take a look here:
http://www.linuxconfig.org/time-countdown-bash-script-example

29
Jun

Check For Empty Directories Using ‘find’ Shell Command

find /path/to/directory -type d -empty -exec echo {} \;

I think it’s easy to get the idea based on the example above, but just in case you need inspiration, you could automatically remove these empty directories with the following (Careful! This uses ‘-rf’ flag which shows no warnings or mercy!):

find /path/to/directory -type d -empty -exec rm -rf {} \;

Check out some additional methods here:

http://www.cyberciti.biz/faq/linux-unix-shell-check-if-directory-empty/

28
Jun

Taking it Easy on Monday with Technobabble

I ran across this video the other day and wanted to share with everyone. Think of it as a light way to start off your week without having to think. Enjoy!
YouTube Preview Image

25
Jun

How To: Add a “Press Any Key to Continue” Message to a Script

Adding a “Press any key to continue” message to a script is actually quite easy because it’s already built into the read command. Here’s a couple examples of how to use it:

#!/bin/sh

echo "A First Method"
read -s -n 1 -p "Press any key to continue..."

# insert echo here for cleaner output
echo

echo "A Second Method"
echo "Press any key to continue..."
read -s -n 1 any_key
echo "Now exiting"
exit 0

Note: “any_key” was simply a made up name. It can be anything. As always, be sure to take a look at the man page for more information!

24
Jun

The Most Dangerous Linux Command

James over at http://dazzle.cs.mcgill.ca has come across a humorous, and frightening, Linux command. It’s been dubbed “The Most Dangerous Command”. Take a look! It makes rm -rf / seem like a PG rated horror film…
http://dazzle.cs.mcgill.ca/wordpress/?p=36

Next Page »

Switch to our mobile site