wait while/until
Amos Shapir
amos at instable.UUCP
Wed Jan 21 22:53:51 AEST 1987
This is a (Bourne) shell file that I've found to be quite useful.
When called as 'ww command' it keeps running 'command' in a loop
until it output changes, then beeps and exits:
ww 'who | grep someone'
tells when 'someone' logs in/out.
When run as 'wu command' (wu is a link to ww), it runs 'command' as long
as its output keeps changing, as in:
wu ls -l incoming_uucp_file
tells when data stops coming.
Flags: -t sec - run 'command' every 'sec' seconds (default 60)
-v - (wu only) show 'command's output every time (default -
show only the final output).
A useful combination is:
wu -v -t 0 ww command &
Runs 'command' in the background, reporting progress every time anything
changes.
(This is not a shell archive - just cut at the dotted line)
o / o / o / o /
-----------------X---------------X---------------X---------------X----
o \ o \ o \ o \
: wait while/until
case $0 in
*u) r='!='; o=x;;
*w) r='=';;
esac
intrval=60
for i
do
case $i in
-t) intrval=$2; shift; shift;;
-v) view=$1; shift;;
*) break;;
esac
done
cmd="$@"
n=`eval "$cmd"`
o="$n"$o
echo "$n"
while [ "$n" $r "$o" ]
do
sleep $intrval
o="$n"
n=`eval "$cmd"`
case $view in
-v) echo "$n";;
esac
done
echo "$n"
o / o / o / o /
-----------------X---------------X---------------X---------------X----
o \ o \ o \ o \
--
Amos Shapir
National Semiconductor (Israel)
6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel
(011-972) 52-522261 amos%nsta at nsc 34.48'E 32.10'N
More information about the Comp.sources.unix
mailing list