Created
November 20, 2012 17:44
-
-
Save chuckwagoncomputing/4119544 to your computer and use it in GitHub Desktop.
shell script to check results of command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
badopts() | |
{ | |
echo -e "Usage: ifchanged [command to check] [number of seconds to wait between checks] [command to execute if not changed] [command to execute if changed]" | |
exit | |
} | |
if [ $# -ne 4 ] | |
then | |
badopts | |
else | |
while true | |
do | |
RES=`$1` | |
sleep $2 | |
NOW=`$1` | |
if [ "$RES" = "$NOW" ] | |
then | |
$3 | |
else | |
$4 | |
fi | |
done | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment