i am busy compiling a script to ping a remote server, when the server is alive i get it to send me an sms, however i cant seem to make the ping stop, can somebody please help? please?
while (9)
set ans="`ping $IPaddress 1`"
if ( "$ans" == "IPaddress is alive" ) continue
sleep 5
echo "is alive"
end
echo out of loopp. my script that i have created is below.
thank you, but this needs to continually ping until the server is up. then once it comes up (say 3am), i dont really want it to continually sms me every 5 seconds till i get to work. i just need to know that the network connection has been reastablished and for the script to them stop running? kind regards
You can schedule it in crontab so that the script runs every minute or so. Do a
man crontab
to see how it works.
As far as the 'not sending sms with error continually' you can have your script write a log every time the server is checked.
Then just before pinging, the script should read the last line of the log
cat log | tail -1
If the last line is Error and the server is still down do nothing.
If the last line is Success and the server is down send 'Warning' SMS
If the last line is Error and the server is up send 'Server is up' SMS
This is the first thing that come into my mind. Maybe someone has a better idea.
If you do something like this, do not forget to clear the log every so often!!