develooper Front page | perl.beginners | Postings from March 2003

Net::Ping Cannot redirect output !

Thread Next
From:
Ramprasad
Date:
March 28, 2003 07:25
Subject:
Net::Ping Cannot redirect output !
Message ID:
3E84696F.4090801@netcore.co.in
I have written a simple script that runs file when I run on command line
but fails when I redirect its output

I cant beleive this , it seems so impossible can anyone help me

$!=1;
use Net::Ping;
@host_array = <DATA>;
$p = Net::Ping->new("icmp");
$p->bind("192.168.2.211"); # Specify source interface of pings
foreach $host (@host_array)  {
   chomp($host);
   print "$host is ";
   print "NOT " unless $p->ping($host, 2);
   print "reachable.\n";
}
$p->close();
__DATA__
192.168.2.1
192.168.2.21
192.168.2.25
192.168.2.212
192.168.2.213
192.168.2.214
192.168.2.215
192.168.2.211
127.0.0.1
192.168.2.144
192.168.2.100
192.168.2.101


When I run the above script it runs fine like this
  perl ping1.pl

when I do
perl ping1.pl >output
I get nothing on screen
the file output  is also empty 8-(


Now How can this happen

Thanks
Ram





Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About