[RC5] dnetc from xscreensaver

Greg Wooledge wooledge at kellnet.com
Tue Jan 25 18:54:55 EST 2000


steve at merlon.com.au (steve at merlon.com.au) wrote:

> #!/bin/sh
> 
> ps ax > ~/ps

Not re-entrant, and not /bin/sh-compatible.  (~ is ksh/bash only.)  Also
does not clean itself up in the event of exit.

Also, do you need to check *all* users' processes, or just your own?

> if [ `grep -c quake ~/ps` -eq 0 ]
> then
> if [ `grep -c dnetc ~/ps` -eq 0 ]
> then
> ~~/dnetc/dnetc -quiet
> fi
> elif [ `grep -c quake ~/ps` -ne 0 ]
> then
> if [ `grep -c dnetc ~/ps` -ge 1 ]
> then
> ~~/dnetc/dnetc -kill
> fi
> fi

Here's a somewhat cleaner version.  It's untested, so use at your
own risk.

=================================================
#!/bin/sh

TMP=$HOME/ps.$$
trap 'rm -f $TMP; exit 1' 1 2 3 15
ps xw >$TMP

DNET=$HOME/dnetc/dnetc

if grep -q quake $TMP; then
    if grep -q dnetc $TMP; then
        $DNET -kill
    fi
else
    if grep -q dnetc $TMP; then
        : do nothing
    else
        $DNET -quiet
    fi
fi

rm -f $TMP
=================================================

-- 
Greg Wooledge                    | "Truth belongs to everybody."
wooledge at kellnet.com             |   Red Hot Chili Peppers
http://www.kellnet.com/wooledge/ |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url : http://lists.distributed.net/pipermail/rc5/attachments/20000125/a8df06b9/attachment-0001.bin


More information about the rc5 mailing list