thanks for that it worked nicely, now my problem is that i need to test another condition before i want the machine to run the reboot command. I have a program called control that i need to test whether it is running, if it is not running i want the machine to reboot so the program will restart on boot up, unless i have the reboot command commented out.
This is what i have at the moment but it doesn't work.
pidno=$(/sbin/pidof -s $CONTROL)
if [ `grep -e '^reboot$' $IAM` ] #check if reboot is enabled
if [ -z "$pidno" ] #if no pid, then process not running
echo "ready to rebboot"
#write to log files
echo "ADS-B Bypass is running"
echo "Reboot is commented out"
i also tried if [ `grep -e '^reboot$' $IAM` ] && [ -z "$pidno" ]
but that didn't work?? i need both the program control failed and the reboot not commented out for the machine to reboot it's self.
If seems that the reboot command needs to be in the direct loop as the if statement with the grep. Is this right??
if i put the following at the bottom of the file
if [ "$ABC" -eq 24 ]
echo "equal to 24"
echo "not equal to 24"
it makes the reboot command in the top if statements work!!! - it doesn't make sense