[plug] Bash "Processing" Script
Bernard Blackham
bernard at blackham.com.au
Fri Jun 11 23:06:08 WST 2004
On Fri, Jun 11, 2004 at 01:53:51PM +0800, Jay Turner wrote:
> while [ true ]
> do
> sleep 3
> echo -n "."
> done
>
> Am I reading it correct that the 'while' is in the background printing dots,
> until we kill the 'while' process
'while' is not a process. It is a control construct within the shell
script - the process executing it is bash (or zsh, etc). You can
break out of the while loop using a 'break' command however, so you
could write Bernd's script in at least two other ways :
dd <dd params> &
DD_PID=$!
while : ; do
sleep 3
echo -n "."
ps $DD_PID >/dev/null || break
done
(ps returns non-zero if it can't find the process and hence will
break out of the loop)
or even
dd <dd params> &
DD_PID=$!
while ps $DD_PID > /dev/null ; do
sleep 3
echo -n "."
done
(as above, the loop only continues while the dd process exists)
Finally, if you can use your own dd, this may be of some use:
http://mail.plug.linux.org.au/pipermail/plug/2003-September/044687.html
HTH,
Bernard.
--
Bernard Blackham <bernard at blackham dot com dot au>
More information about the plug
mailing list