Hi,
I am not sure, whether you are looking like this or not.
#!/bin/bash
GW=<Gateway IP>;
ping -c 1 $GW > /dev/null
exitstatus=$?;
[ $exitstatus -eq 0 ] && [ ! -e ~/enable ] && <command to run> && touch ~/enable && exit # This line will execute after getting the connection
[ $exitstatus -ne 0 ] && rm ~/enable && <command to execute> # This line will execute at the end
I hope this logic will work... but didn't check..
--
Thanks,
Bijo
Last edited by bijo505; 12-24-2012 at 12:05 AM.
Reason: Exit status was not properly mentioned.
|