To add to Bob's statement, just to provide more info...

I would get some ps output, maybe like this:

my @psfull = `ps -ef`;

Then I could mess around with @psfull all want:

if (@psfull =~ /(^\d+)\s+\d+dhcpd/) {
        $pid = $1;
        do some stuff to $pid...

Read the regular expression section of Learning Perl. Also there's
(probably) a section about backticks vs system().

Of course the regex would probably be different, since as Bob said ps is
hardly a standard and the output you get will probably be different than
anything I could use as an example. Take some sample output and figure out
how to get the info you want.

-=GLA=-

> Hi, I wonder how can I know if a process for exemple dhcpd is
> running and if it
> is how can I kill it in Perl.
> Thanks

If you know the PID, Perl has a kill() function:

perldoc -f kill

To find the PID is trickier. Some daemons write their pid to a file.
For others, parsing the output of ps is probably the best way to go,
but even that tends to be highly OS-specific.

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



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

Reply via email to