Subject: | Pb with Net::Ping and print statement |
Hello,
First :
This is perl, v5.6.0 built for i386-linux
Package Net-Ping-2.31.tar.gz
OPerating system : Linux pcmngt.pssc_network 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown
Second :
I have a script perl which must increment a variable and print this variable on screen. when I use the Net::Ping package to use that, there is nothing on screen and variable is printed only at the end of the scan.
I think a sample will be more explicit. Here is a code derivated from the sample found on man page for Net::Ping :
***********************************************************
#!/usr/bin/perl -w
use Net::Ping ;
use strict ;
my $host ;
my @host_array = qw (192.168.1.10 192.168.1.11 192.168.1.12 192.168.1.13) ;
my $p = Net::Ping->new("icmp");
$p->bind("192.168.1.48"); # Specify source interface of pings
foreach $host (@host_array)
{
print "$host is ";
print "NOT " unless $p->ping($host, 1);
print "reachable.\t"; # <===CHANGE IS HERE
sleep(1);
}
$p->close();
exit ;
******************************************************************
From the sample provided, I just changed from "\n" to "\t" which is TAB. In this case, assuming that the first 2 hosts are not reachable (.10 and .11), the scrip prints on screen only after the end of the script.
If I use "\n" instead of "\t", the scrip prints all sentences one after the other using the right way.
I don't see any entry about this problem anywhere. I am not a Perl guru and I don't think to be able to look at the Net::Ping package to try to solve this pb.
It will be so great if you have the time to look at this problem and tell me how to solve it.
Many thanks in advace for your help.
Pascal MARACHIAN