[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash: finding if mozilla is running



On Sat, 26 Jul 2003 13:50:05 +0200, Seneca wrote:

> On Sat, Jul 26, 2003 at 10:22:53AM +0100, David selby wrote:
>> Writting a small script to make mozilla show the results of HTML code
>> written in vi, when vi saves, the script  automaticly changes mozilla
>> to show that HTML.
>> 
>> I need to know if mozilla is running, if not I need to call it first
>> ... seemed simple
>> 
>> if ! ps ax | grep "mozilla-bin" &>/dev/null; then
>>        /usr/local/mozilla/mozilla -P web &
>>        .....
> [...]
>> Ie its picking up on the grep process, finding "mozilla-bin", saying
>> yep its running, dont call mozilla & bang, script fails.
> 
> ps --no-headers -C "mozilla-bin" | grep -q -- "-bin"

Why grep? ps returns != 0 if no mozilla-bin process can be found and == 0
if one is found.

	ps -C mozilla-bin >/dev/null

should cover it.

-- 
Best Regards,   |   Hi! I'm a .signature virus. Copy me into
 Sebastian      |   your ~/.signature to help me spread!



Reply to: