I am not sure, whether you are looking like this or not.
ping -c 1 $GW > /dev/null
[ $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..
Last edited by bijo505; 12-24-2012 at 01:05 AM.
Reason: Exit status was not properly mentioned.