I'm trying to grab batches of input from a remote pipe via ssh. My script below works ok, but I would like to add some sort of check into it so that if something were to go wrong or break the loop would end if the script started running away.
How can I add in a component that would check if the loop ran, say 5 times in 3 seconds then the script would break the loop and auto terminate?
#!/bin/sh if [ -z "$1" ] then echo " usage: user@host" echo exit fi while [ 1 ] do CB=`ssh $1 cat clipboardpipe` if [ -n "$CB" ] then echo $CB | /usr/bin/pbcopy echo $CB | /usr/local/bin/growlnotify fi sleep 1 done
ps: I had looked at using something like
tail -f but it didn't seem to work when other programs expect input in batches. All advice is welcome.
clipboardpipe is a named pipe in the home directory on the remote system.