On Sun, Apr 6, 2008 at 12:29 PM, Ian <ianhoweire at gmail.com> wrote:
> I'm basically launching a program in the background using a sh script.
>> firefox http://www.google.ie>> (side note: this also launches the terminal, is there a way to prevent
> this?)
It *shouldn't* launch a terminal, to be honest, unless your environment
decides that it needs somewhere to put the output of the command. What
environment is this (KDE, GNOME, etc?) and what are you using to launch the
shell script?
then i want to have another script that can kill the process.
> I presume i am only able to kill the process using the pid using the
> format
> 'kill 1234'
> I can use the following line to copy the pid to a file
>> ps -e | grep firefox-bin | cut -d ' ' -f2 > ~/processID
>> how then can i pass the entry in processID to the kill command.
> Or if there is another way to do this i''m all ears.
killall firefox-bin
Or, if you really do want to do it using the above:
kill `ps -e | grep firefox-bin | cut -d ' ' -f2`
Note the backticks. Most modern shells will also allow $(), so:
kill $(ps -e | grep firefox-bin | cut -d ' ' -f2)
will also work. killall is easier, though. Note : I believe the Linux
killall has different semantics from the Unix one; if you run killall on
(eg:) a Solaris system, it will send a signal to all processes, not just the
named ones.
Colm
>>> Ian
> --
> Irish Linux Users' Group mailing list
> About this list : http://mail.linux.ie/mailman/listinfo/ilug> Who we are : http://www.linux.ie/> Where we are : http://www.linux.ie/map/>
--
Colm Buckley / colm at tuatha.org / +353 87 2469146
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!