Re: bash: finding if mozilla is running

2003-07-28 Thread Aaron
On -5360-Sat, Jul 26, 2003 at 02:21:52PM +0200, Sebastian Kapfer [EMAIL PROTECTED] 
spake thus,
 On Sat, 26 Jul 2003 11:30:06 +0200, David selby wrote:
 
  I need to know if mozilla is running, if not I need to call it first ...
  seemed simple
 
 Yeah. That's why I use Galeon. I never understood Mozilla's remote
 control. :-) Of course, Galeon has other advantages, too...
 
  Whatever I grep for, grep will find in ps ax as grep xx, a bit
  frustrating !!
 
 use ps -C mozilla-bin, no grep
 
 -- 
 Best Regards,   |   Hi! I'm a .signature virus. Copy me into
  Sebastian  |   your ~/.signature to help me spread!
 
 
 -- 
 To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
 with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]

I use a small shell script to get the behavior I'm used to from
similar browsers in Windows where if the app is running I get a new
tab, but if it's not it launches to the specified URL. Here it is,
hopefully it's some help to someone (I hate it when it's already
running and something tries to run it again to display a URL and I get
the profile selection dialog!):

I know there's probably a better (e.g. shorter) way to achieve this
result, but I'm not a bash scripting master yet.

#!/bin/bash

# Count the number of instances of 'mozilla-bin' in my process list.
MOZ=`ps waux | grep mozilla-bin | wc -l`

# If there seems to be more than one instance (moz always seems to
# start more than one thread when it's running)...
if [ $MOZ -gt 1 ]; then
# Cause the running Mozilla to open a new tab to the URL...
`mozilla -remote openurl($1,new-tab)`
else
# Or just open a new Mozilla to the URL...
`mozilla $1 `
fi

Cheers.

-- 
Aaron Bieber
-
Graphic Design // Web Design
http://www.core-dev.com/
[EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash: finding if mozilla is running

2003-07-27 Thread Richard Heycock
On Sat, 2003-07-26 at 19:22, David selby wrote:
 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
 
 [EMAIL PROTECTED]:/usr/local/myfiles/dave/debian/sh files$ ./HTMLgui
  7508 pts/0S  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 xx, a bit 
 frustrating !!

grep -v grep will ensure that the grep line is removed. eg

if ! ps ax | grep mozilla-bin | grep -v grep ...

rgh

 
 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
-- 
It is possible to make things of great complexity out of things
 that are very simple. There is no conservation of simplicity
 -- Stephen Wolfram

Richard Heycock [EMAIL PROTECTED]
tel : 0410 646 369
key fingerprint : 909D CBFA C669 AC2F A937 AFA4 661B 9D21 EAAB 4291


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



bash: finding if mozilla is running

2003-07-26 Thread David selby
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

[EMAIL PROTECTED]:/usr/local/myfiles/dave/debian/sh files$ ./HTMLgui
7508 pts/0S  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 xx, 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


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash: finding if mozilla is running

2003-07-26 Thread Seneca
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

-- 
Seneca
[EMAIL PROTECTED]


pgp0.pgp
Description: PGP signature


Re: bash: finding if mozilla is running

2003-07-26 Thread Sebastian Kapfer
On Sat, 26 Jul 2003 11:30:06 +0200, David selby wrote:

 I need to know if mozilla is running, if not I need to call it first ...
 seemed simple

Yeah. That's why I use Galeon. I never understood Mozilla's remote
control. :-) Of course, Galeon has other advantages, too...

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

use ps -C mozilla-bin, no grep

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


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash: finding if mozilla is running

2003-07-26 Thread Sebastian Kapfer
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!


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash: finding if mozilla is running

2003-07-26 Thread David selby
David selby wrote:

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

[EMAIL PROTECTED]:/usr/local/myfiles/dave/debian/sh files$ ./HTMLgui
7508 pts/0S  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 xx, 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


Many thanks for all your help, works great now,
Dave
PS what is this Galleon thing ?



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash: finding if mozilla is running

2003-07-26 Thread Shyamal Prasad

David == David selby [EMAIL PROTECTED] writes:

David PS what is this Galleon thing ?

That's any easy question to answer ;-)

$ dpkg -p galeon
Package: galeon
Priority: optional
[...deleted.]
Description: Mozilla based web browser with GNOME look and feel
 Galeon is a fast Web Browser for the GNOME Desktop Environment.
 .
 Galeon's use of Mozilla's Gecko rendering engine makes it more feature
 complete and standards compliant than most other browsers available.
 .
 By using the GNOME and GTK libraries for the user interface, Galeon is
 usually faster than mozilla and the interface integrates well with the
 GNOME Desktop Environment.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash: finding if mozilla is running

2003-07-26 Thread Alan Connor
 From [EMAIL PROTECTED] Sat Jul 26 07:35:08 2003
 
 
 
 
 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=20
  written in vi, when vi saves, the script  automaticly changes mozilla to=
 =20
  show that HTML.
 =20
  I need to know if mozilla is running, if not I need to call it first ...=
 =20
  seemed simple
 =20
  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=
 =20
  its running, dont call mozilla  bang, script fails.
 
 ps --no-headers -C mozilla-bin | grep -q -- -bin
 


This might help in the future, Seneca:

ps a  | grep slrn | grep -v grep
  863 pts/3S  0:00 slrn


Alan


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash: finding if mozilla is running

2003-07-26 Thread Greg Norris
On Sat, Jul 26, 2003 at 07:36:47AM -0700, Alan Connor wrote:
 This might help in the future, Seneca:
 
 ps a  | grep slrn | grep -v grep
   863 pts/3S  0:00 slrn

You can cut out an unnecessary process (not that it's likely to be a
big deal these days) with: 

  ps a | grep [s]lrn


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash: finding if mozilla is running

2003-07-26 Thread K S Sreeram
 This might help in the future, Seneca:
 
 ps a  | grep slrn | grep -v grep
   863 pts/3S  0:00 slrn
 
 

There's always the 'pgrep' command

just do:

pgrep slrn

-ks


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]