[Perl-unix-users] getting putput of ping command into file

2003-01-15 Thread ppathan
Hi gurus,
I am trying to get the output of ping into a filehandle. My problem
is that this program works on one Linux box and throws up an error on
another.
Pls tell me where am I goofing up.


 ## I get an error in this part
open(PING,"-|","ping -c 30 192.168.1.1") || die "Cannot ping to
192.168.1.1 : ", $!,"\n";


while($line = )
{
print $line if($DEBUG == 1);

chomp $line;

## lots of further processing...

} ## end of while



I tried to run it on 2 Linux boxes with one working fine. foll is the
"uname -a" output of this one:
Linux m3 2.4.6 #7 Tue Jul 3 14:32:36 IST 2001 i686 unknown


Then I took the "uname -a" output of the erroneous one :
Linux shiva 2.4.13 #2 Fri Nov 2 07:09:41 IST 2001 i686 unknown


Can anyone pint out the mistake to me.

Regards,
Parvez

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: [Perl-unix-users] getting putput of ping command into file

2003-01-15 Thread Scott Purcell
You can take the output from the command and put it into an array like so.

This seemed to work, I am usign cygwin, and I couldn't find your -c switch. But maybe 
this could help...

#! perl

use strict;


my $cmd = "ping -n 3 127.0.0.1";


print "Begin", "\n";

open (PING, "$cmd |") or die("Problem somewhere. $!");
my @pings = ;
close PING;

foreach (@pings) {
print;
}


Scott Purcell



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 15, 2003 4:02 PM
To: Perl-Unix-Users
Subject: [Perl-unix-users] getting putput of ping command into file


Hi gurus,
I am trying to get the output of ping into a filehandle. My problem
is that this program works on one Linux box and throws up an error on
another.
Pls tell me where am I goofing up.


 ## I get an error in this part
open(PING,"-|","ping -c 30 192.168.1.1") || die "Cannot ping to
192.168.1.1 : ", $!,"\n";


while($line = )
{
print $line if($DEBUG == 1);

chomp $line;

## lots of further processing...

} ## end of while



I tried to run it on 2 Linux boxes with one working fine. foll is the
"uname -a" output of this one:
Linux m3 2.4.6 #7 Tue Jul 3 14:32:36 IST 2001 i686 unknown


Then I took the "uname -a" output of the erroneous one :
Linux shiva 2.4.13 #2 Fri Nov 2 07:09:41 IST 2001 i686 unknown


Can anyone pint out the mistake to me.

Regards,
Parvez

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: [Perl-unix-users] getting putput of ping command into file

2003-01-15 Thread Gerber, Christopher J
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 5:02 PM
> To: Perl-Unix-Users
> Subject: [Perl-unix-users] getting putput of ping command into file
> 
> 
> Hi gurus,
> I am trying to get the output of ping into a filehandle. 
> My problem
> is that this program works on one Linux box and throws up an error on
> another.
> Pls tell me where am I goofing up.
>

What sort of error are you seeing?  Does the ping not make it to/from the
host, or does the ping command not work?  What is the result of a "which
ping" on each machine?  Would "./ping -c 30 192.168.1.1" work any better?
 
> 
>  ## I get an error in this part
> open(PING,"-|","ping -c 30 192.168.1.1") || die "Cannot ping to
> 192.168.1.1 : ", $!,"\n";
> 
> 
> while($line = )
> {
> print $line if($DEBUG == 1);
> 
> chomp $line;
> 
> ## lots of further processing...
> 
> } ## end of while
> 
> 
> 
> I tried to run it on 2 Linux boxes with one working fine. foll is the
> "uname -a" output of this one:
> Linux m3 2.4.6 #7 Tue Jul 3 14:32:36 IST 2001 i686 unknown
> 
> 
> Then I took the "uname -a" output of the erroneous one :
> Linux shiva 2.4.13 #2 Fri Nov 2 07:09:41 IST 2001 i686 unknown
> 
> 
> Can anyone pint out the mistake to me.
> 
> Regards,
> Parvez
> 

Sorry for only questions and no answers...

Chris


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. 
It is intended for the addressee(s) only. Access to this E-mail by anyone else is 
unauthorized. If you are not an addressee, any disclosure or copying of the contents 
of this E-mail or any action taken (or not taken) in reliance on it is unauthorized 
and may be unlawful. If you are not an addressee, please inform the sender immediately.
___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs