Re: Learning Scripting
Thanx, Michael and Andrew. Here is my first usable shell script, thanx to your
The idea was the system cannot start the X-Server sometimes when the power goes
off unexpectedly. So, if an error message is found the system should be
shutdown nicely and then when it reboots, it runs an fsck and cleans up.
The second set of checks is because sometimes the grep command itself appears in
the ps ax, and we do not want to reboot for this spurious occurrence.
msg2="yesno I cannot start the X server"
check1=$(ps ax | grep -i "$msg1")
check10=$(echo $check1 | grep -i "grep")
check2=$(ps ax | grep -i "$msg2")
check20=$(echo $check2 | grep -i "grep")
if [ $count10 -gt 0 ]
if [ $count20 -gt 0 ]
if [ $count1 -gt 0 ] || [ $count2 -gt 0 ]
echo "Found it!"
shutdown -r now
echo "Not found!"
----- Original Message -----
From: "Andrew Sackville-West" <email@example.com>
Sent: Monday, May 15, 2006 11:29 PM
Subject: Re: Learning Scripting