Yosef Meller <[EMAIL PROTECTED]> writes: > ps -A | grep -i firefox > /dev/null
I think you are in danger here: your grep is a separate process and it *may* appear in the process table and be grepped (since the command line contains what you are looking for) even when firefox is not run. There is no lock that says grep does not start until ps finishes reading the process table. One useful trick is "egrep -i [f]irefox", another is "grep -v grep". RedHat have /usr/bin/pgrep and /usr/bin/pkill utilities, and I have used pname () { /bin/ps auxww | /bin/egrep "$@" | /bin/grep -v egrep } pnum () { pname "$@" | /bin/awk '{print $2}' } pkill () { kill -9 `pnum [EMAIL PROTECTED] } in my .bashrc since before RedHat introduced theirs. Another, related point: your script is only good for a single-user machine. Since "ps -A" lists *all* processes then your grep may find someone else's firefox. You will be better off parsing the long output of ps and finding your own firefox. E.g. RedHat's pgrep will allow that. Finally, it should be relatively easy to make your script work for any browser that supports a variant of "-remote" option. You may pass the browser and the option on the command line, or via the environment, with "firefox" and "-remote" as default values. -- Oleg Goldshmidt | [EMAIL PROTECTED] ================================================================= 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]