Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Searching strings within an array for a particular word.

by stephen (Priest)
on Mar 06, 2002 at 01:56 UTC ( #149587=note: print w/ replies, xml ) Need Help??


in reply to Searching strings within an array for a particular word.

Instead of using ps and grep, why not use Proc::ProcessTable? If you're on one of its supported systems (and quite a few are supported), you can use it to parse the process table instead of the ps command. Then you could do (untested and probably wrong, since I have no access to this module):

use strict; use Proc::ProcessTable; sub is_running { my ($pattern) = @_; my $t = Proc::ProcessTable->new(); foreach $proc ( @{ $t->table() } ) { $proc->cmndline() =~ /^$pattern/ and return 1; } return 0; }
You might also want to take a look at Watchdog.

stephen


Comment on Re: Searching strings within an array for a particular word.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://149587]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2015-07-07 23:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls