On Wed, 26 Dec 2007 17:50:44 +0200, Oded Arbel wrote: > > On Wed, 2007-12-26 at 16:02 +0200, Tom Rosenfeld wrote: > > pgrep ssh |tail -1 > > they way I read it ... > ... it looks like there will be a race condition here. > > Maybe I could filter on "session id" or "process group id" if I would > know how to set it.
Here is a little trick that will solve the race condition - create a unique name for the ssh you run. Example of use in bash: SSH=`which ssh` # locate ssh on PATH NSSH=my_ssh_$$ # unique ssh name (you can add $USER, time ...) TSSH=/tmp/$NSSH # abs name rm -f $TSSH # may be we have leftovers ln -s $SSH $TSSH # create it on /tmp $TSSH command parameters & # run the ssh in BG rm -f $TSSH # remove symbolic link (not needed any more) PID=`pgrep $NSSH` # find pid of MY ssh Ehud. -- Ehud Karni Tel: +972-3-7966-561 /"\ Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign Insurance agencies (USA) voice mail and X Against HTML Mail http://www.mvs.co.il FAX: 1-815-5509341 / \ GnuPG: 98EA398D <http://www.keyserver.net/> Better Safe Than Sorry ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]