Gary Stainburn wrote:
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]$

Don't you mean 'ping -n -c 50 10.1.1.31' instead of 'ping -n 50 10.1.1.31'. Else read the man page for ping.

--
Flemming Greve Skovengaard                     Man still has one belief,
a.k.a Greven, TuxPower                         One decree that stands alone
<[EMAIL PROTECTED]>                    The laying down of arms
4112.38 BogoMIPS                               Is like cancer to their bones


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