On Tue, Apr 16, 2002 at 12:49:40PM +0100, Dermot Paikkos wrote:
> Hi Guru's
> 
> SYS stuff: perl 5.05 on Tru64 Unix.
> 
> I am writing a script that needs to find the process IDs of a couple of 
> processes (so they can be killed nicely). Under the csh i would usually 
> do "ps -e| grep process". I am not sure if I can do something like this 
> using system or if there is a module that would save a lot of work. 
> I was thinking of doing something like:
> $output = `system(ps -e)` and doing some regexp on $output. 
> Would that seem like the way to go?

Yepp, backticking ps is much easier to do portable than using the proc
filesystem structures... (Surfing over to search.cpan.org I found
Proc::ProcessTable which looks as if it supports a vast variety of
different platforms, so you might take look at this too.)

But keep in mind that there are still alot of differences in the output
of ps among platforms.

BTW: it's 

    $output = `ps -e`

You don't need the 'system' inside the backquotes.  Think about using
qx{} instead of the backquote operator if you need to do more complex
stuff in the shell.

-- 
                       If we fail, we will lose the war.

Michael Lamertz                        |      +49 221 445420 / +49 171 6900 310
Nordstr. 49                            |                       [EMAIL PROTECTED]
50733 Cologne                          |                 http://www.lamertz.net
Germany                                |               http://www.perl-ronin.de 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to