Tuesday, November 29, 2005


Cannot open '/etc/path_to_install' Error Message

This happened to me just today and I had to go online to find a solution. The site Admin's Choice.com had the answer and it appears to be a good resource for admin problems in general.

The short answer is from the ok prompt enter boot -ar and take the default answers for each question until this prompt appears:

The /etc/path_to_inst on your system does not exist or is empty. Do you want to rebuild this file [n]?

Answer Y and then answer with the default on the rest of the questions. It fixed the problem for me at least. The same page has a list of other potential boot time problem fixes as well.


Saturday, November 26, 2005


Referring to Script Source Files Within a Script

Eventually the time will come when you've written some really great functions and want to reuse them in new scripts. THis is easy enough to do in a simple referencing scheme.

First put your code in a file. In this case we want something simple like a formatted date/time stamp.

DateTimeStamp () {
# Generate a date stamp variable.
DateStamp=`date +%y%m%d%H%M%S`

Let's name this file datestamp.ksh.

Now in the same directory we want to include this file so we can use the DateStamp

# Example Script
# Writ by JollyFatMan
. ./datestamp.ksh
# The period beginning the line is a command to import the source code from the
# named file. It does not have to be executable to work. After including the file
# the contents may be used as if the code were actually part of the existing script.
echo $DateStamp
read WI
exit 0
# End of Script

Have Fun!

Monday, November 21, 2005


Network Troubleshooting with Ping

The ping command is useful to determine if a remote device is up and reachable. It sends out an ICMP packet to the remote host which then responds back to your host.

If you only enter ping hostname, the program /usr/sbin/ping will simply respond with an 'is alive' response or 'no answer from host' if the remote hosts does not reply within the timeout(default is 20 seconds).

If you must determine the quality of the connection, then ping statistics are necessary. To do this, simply enter:

ping -I 1 hostname

The ping will then run continuously until you hit CTL-C.
When aborted the ping will print ping statistics.

Example Output:

PING IP Address: 56 data bytes
64 bytes from hostname (IP Address): icmp_seq=0. time=1. ms
64 bytes from hostname (IP Address): icmp_seq=1. time=1. ms
64 bytes from hostname (IP Address): icmp_seq=2. time=1. ms
64 bytes from hostname (IP Address): icmp_seq=3. time=1. ms
64 bytes from hostname (IP Address): icmp_seq=4. time=1. ms
64 bytes from hostname (IP Address): icmp_seq=5. time=1. ms
64 bytes from hostname (IP Address): icmp_seq=6. time=1. ms
64 bytes from hostname (IP Address): icmp_seq=7. time=1. ms
64 bytes from hostname (IP Address): icmp_seq=8. time=1. ms
64 bytes from hostname (IP Address): icmp_seq=9. time=1. ms

----IP Address PING Statistics----
10 packets transmitted, 10 packets received 0% packet loss
round-trip (ms) min/avg/max = 1/1/1

The ping will report the number of lost packets, and the ping return statistics. This becomes most useful in determining the quality of the network connection. To do this it helps to run the ping for a minimum period of 1 hour and 24 hours is preferable.

This code snippet will run statistics for the ping over an hour and record the output in a file. Create a file named Ping.ksh, add the code lines, save and make it excecutable. Then to run it just enter "./Ping.ksh hostname" and hit enter.

# Capture Ping Statistics
# Writ by JollyFatMan
DateTime=`date +%y%m%d%H%M%S`
Archive="tee -a ./$PingArchive"
echo "Ping $1 Date/Time Started: "`date`|$Archive
trap "" 2
ping -I 1 $1 56 $PingCount|$Archive
echo "Hit Enter To Finish:"
trap ":" 17
(sleep 60;kill -17 $$ 2>/dev/null)&
read WI
if kill -0 $! 2>/dev/null
kill $! 2>/dev/null
echo "Ping $1 Date/Time Finished: "`date`|$Archive
trap 17
trap 2

If you wish to quit sooner, just hit CTL-C. The statistics will be recorded to a file named after the hostname with a date/time stamp appended to it.

Keep ping statistics of all your important network connections so when problems arise you have something to compare your diagnostics to.

Have Fun!


Sunday, November 20, 2005


Korn Shell Basics Link

Here is a decent link for Korn Shell Scripting basics at Bolthole.com



Coding a Response Trap in a Korn Shell Script

There will eventually be a time when you want to obtain input from the user but also need to refresh the display information for the user to look at. A trap is an effective means to do this:

Example Code:

trap ":" 17
(sleep 60;kill -17 $$ 2>/dev/null)&
read Response
if kill -0 $! 2>/dev/null
kill $! 2>/dev/null
trap 17

The ":" is a place keeper only, as the trap needs something to execute. A null value in the trap will actually do nothing.

The 17 tells the trap to focus on return code 17.

The (sleep 60;kill -17 $$ 2>/dev/null)& spawns a sub-process with the code in the brackets. The mini script will sleep for 60 seconds and then run a kill of the current command (referenced by $$ in the script). The 2> /dev/null simply tells the kill to pipe error messages to the bit bucket.

The next command is the read command and it gathers input from the user. If the user has not entered any info, the read will still be active and the kill will end the read and continue execution of the script.

The if statement will kill the sub-process so it cannot kill any other current commands and the trap 17 will end the section of code the trap is intended to operate on.

Sweet and simple.