On Tuesday, June 4, 2002, at 02:38 , John W. Krahn wrote:
[..]
>> #!/usr/bin/perl
>> @SERVERS = qw(itsux17 its29 itsux24 int-dns1 int-dns2 mrtg defgtway);
>> for $S ( @SERVERS ) {
>>     for ( `/etc/ping $S 32 -n 6` ) {
>>         if ( /trans/ ) {
>>             ( $PING1 = $_ ) =~ s/\D+//g;
>
> Sorry, missed a step.  :-)
>
>              ( $PING1 = (split)[6] ) =~ s/\D+//g;
>

first off my complements for working as close to a shell
script as is possible....

[..]

good try there.....

but notice that your first one squeezes out all of the 'space'
and would in the case of say

        6 packets transmitted, 6 packets received, 0% packet loss

convert that into

        660

hence your second one would give you at best questionable data
since there are not 'six fields'..... or are you aware of
the peculiar formatting that actually comes out of the process...


as a piece of test code scope

        my $PING1='SPAGO';
        print "And it is now $PING1 \n";
        my $word = " fred123456789bob";

        if ($word =~/fred/ ) {
                s/\D+//g;
                $PING1 = (split)[6] ;

        }
        $PING1 ||='FreMonge';
        print "final ping is: $PING1 \n";

or am I missing something in the voodoo????


ciao
drieux

---


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

Reply via email to