I think I begin to understand...

I begin by fetching the results of the ps -efA command and split it into many 
variables ($uid, $pid, etc.)

    open(PS, "ps -efA|"); 
    while (<PS>) { 
        ($uid,$pid,$ppid,$c,$stime,$tty,$time,$cmd) = split;
        
        if ($cmd =~ /dispatch genie/)  {
            $infos{$pid}{'uid'}   = $uid;
            $infos{$pid}{'ppid'}  = $ppid;
            $infos{$pid}{'c'}     = $c;
            $infos{$pid}{'stime'} = $stime;
            $infos{$pid}{'tty'}   = $tty;
            $infos{$pid}{'time'}  = $time;
            $infos{$pid}{'cmd'}   = $cmd;


I thought $cmd, as the last variable for the split command, would contain the next 
word and also the rest of the line, which it does not. It seems to take only the next 
word and do nothing with the rest of the line.

So $cmd contains /prog/gena/8.1.1/bin/dispatch 

NOT /prog/gena/8.1.1/bin/dispatch genie -u /prog/gena/impress/gui/im

Steve Hemond
Programmeur Analyste / Analyst Programmer
Smurfit-Stone, Ressources Forestières
La Tuque, P.Q.
Tel.: (819) 676-8100 X2833
[EMAIL PROTECTED] 



 > -----Original Message-----
 > From: Ed Christian [mailto:[EMAIL PROTECTED] 
 > Sent: Wednesday, December 17, 2003 11:40 AM
 > To: Hemond, Steve
 > Cc: [EMAIL PROTECTED]
 > Subject: RE: RE : Regular expressions
 > 
 > 
 > Hemond, Steve wrote:
 > > Okay, here`s the real problem,
 > > 
 > > # ps -efA |grep dispatch
 > > cspenard 33958 45716   0 09:08:05  pts/8  0:00
 > > /prog/gena/8.1.1/bin/dispatch genie -u /prog/gena/impress/gui/im
 > > msirois 37212  9842   0 08:41:17  pts/1  0:04
 > > /prog/gena/8.1.1/bin/dispatch genie -u /prog/gena/impress/gui/im
 > > 
 > > My script passes each process and when it finds "dispatch 
 > genie" it 
 > > holds its data in a hash table.
 > > 
 > > As you can see, dispatch genie is found in these two columns.
 > > 
 > > if ($cmd =~ /dispatch genie/)  {
 > > 
 > > That returns absolutely nothing.
 > > 
 > > Why?
 > > 
 > 
 > 
 > Again, that regexp works just fine. (If you're setting $cmd 
 > properly...) Something else must be wrong that you're not 
 > sending in your email requests. Send the actual code.
 > 
 > #!/usr/bin/perl -w
 > use warnings;
 > use strict;
 > 
 > while (<DATA>) {
 >     chomp;
 >     (/dispatch genie/) ? print "Hit\n" : print "Miss\n";
 > }
 > 
 > __DATA__
 > cspenard 33958 45716   0 09:08:05  pts/8  0:00
 > /prog/gena/8.1.1/bin/dispatch genie -u /prog/gena/impress/gui/im
 > msirois 37212  9842   0 08:41:17  pts/1  0:04
 > /prog/gena/8.1.1/bin/dispatch genie -u /prog/gena/impress/gui/im
 > 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to