Hi folks.

Got the simplest of small scripts that runs ping and shows the summary.  
However, although the ping command works at the shell, it doesn't work 
in the perl script.

any ideas?

#!/usr/bin/perl -w

while(1) {
  my @lines=qx{ping -n 50 10.1.1.31};
  my $times=pop @lines;
  my $counts=pop @lines;
  print "$times $counts";
  if ($times=~/^(\d+) .?, (\d+) .?, (\d+%)/) {
    $sent=$1;
    $rec=$2;
    $perc=$3;
    printf "%3d %3d %3d %s", $sent,$rec,$perc,$times;
  }
  sleep 60;
}

#--- lswitchh.ringways.co.uk ping statistics ---
#120 packets transmitted, 120 packets received, 0% packet loss
#round-trip min/avg/max/mdev = 0.243/0.391/0.834/0.079 ms
[EMAIL PROTECTED] gary]$ ping  lswitchh
#

[EMAIL PROTECTED] gary]$ ./pingcheck
connect: Invalid argument
Use of uninitialized value in concatenation (.) at ./pingcheck line 7.
Use of uninitialized value in concatenation (.) at ./pingcheck line 7.
Use of uninitialized value in pattern match (m//) at ./pingcheck line 8.
^C
[EMAIL PROTECTED] gary]$
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     


-- 
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