Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: ps aux and perl

by lemming (Priest)
on Aug 21, 2001 at 23:19 UTC ( [id://106705]=note: print w/replies, xml ) Need Help??


in reply to ps aux and perl

Some pseudo code:
open pipe from ps aux, perhaps after grepping for sendmail while(<PIPE>) { my ($owner, $pid, undef, undef, undef, undef, undef, undef, undef, undef, # Throw +eight values away $command_withIP) = split(' ', $_, 11); Do stuff }

Update: What c suggests is a good path to take, especially since the ps table is rather transitory. You won't be sure of having a pid match. If the log doesn't have the IP address, I'm sure that can be set via sendmail.cf. You may also want to look into /etc/mail for some more clues.

Update2: thank you bbfu

Replies are listed 'Best First'.
(bbfu) (lists and x operator) Re2: ps aux and perl
by bbfu (Curate) on Aug 22, 2001 at 02:03 UTC

    I assume that the 'j' in $j[1..8] stands for 'junk'... If you're actually going to not use those variables, you might consider using the following idiom to reduce the number of unused lexical variables created, 'variable used only once' warnings, and typing. ;)

    my ($owner, $pid, (undef) x 8, $command_withIP) = split(' ', $_, 11);

    Anyway, it's just a thought. Take it or leave it. :-)

    Update: D'oh! Forgot necessary spaces around the x operator. Thanks lemming. :-)

    bbfu
    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.

Re: Re: ps aux and perl
by Jerry (Scribe) on Aug 22, 2001 at 00:08 UTC
    When I run this code, $command_withIP contains the whole line, not the command with ip. For some reason, the splits ppl recommend don't seem to work at all.

    -Jerry
    http://www.digilliance.net

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-24 19:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found