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

bash: finding if mozilla is running



Hello,

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 &
       .....

This worked the first time then I get

web@debian:/usr/local/myfiles/dave/debian/sh files$ ./HTMLgui
7508 pts/0    S      0:00 grep mozilla-bin

Ie its picking up on the grep process, finding "mozilla-bin", saying yep its running, dont call mozilla & bang, script fails.

Whatever I grep for, grep will find in ps ax as grep xxxxxx, a bit frustrating !!

Help
Dave

PS still a newbe BASH scripter, If there is a better way of doing this, let me know.


#!/bin/sh

# HTMLgui ... enable Mozilla to provide a GUI for vi

currentdir=/usr/local/myfiles/dave/websites/current
oldhtml="mismatch"


if ! ps ax | grep "mozilla-bin"; then
       /usr/local/mozilla/mozilla -P web &
       sleep 3s
fi

echo
while true; do
html=$(ls -t1 $currentdir/*.html | head -n 1)
if [ $oldhtml = $html ]; then
       sleep 1s
else
       echo -e "HTMLgui ... changing to ${html##/*/}"
       oldhtml=$html
       /usr/local/mozilla/mozilla -P web -remote "openFile($html)"
fi
done




Reply to: