> Thks for your advise. > The problem I have encountered was running the following script. > --------------------- > #!/perl/bin/ > use CGI qw/:standard/; > use Net::Ping; > $q=new CGI; > $z=Net::Ping->new("icmp"); > $host="1.21.83.8"; > $x=0; > > print $q->header(-type=>'text/html'), > $q->start_html('hello world'); > > while ($x<3){ > print "$host is "; > print " NOT " unless $z->ping($host,2); > print " Alive","<p>"; > $x++; > } > print $q->end_html; > >> --------------------------- > > Though the script does print out the result, but the result was print out > only after it has completed the iteration. I was expecting that it will > print out the result one after another so that the user would not think that > the server is not responsing. >
<[EMAIL PROTECTED]> wrote in message 00ba01c23278$a62174f0$d381f6cc@david">news:00ba01c23278$a62174f0$d381f6cc@david... > Samuel, > Well, you could hop on cpan.org and find yourself a module that will do the ping for you, or you > could use a less proper method like the following: > > ----------------------------------------- > # pretend you got $ipaddress through CGI.pm or something like that > print "Content-Type: text/html\n\n"; > my $result = `ping -c 1 $ipaddress`; > if ($result =~ /1 packets? received/){ > # ping successful > print "Ping Successful, Result:\n<br>" . $result; > } else { > # ping failed > print "Ping Failed, Result:\n<br>" . $result; > } > ----------------------------------------- > > Regards, > David > > > > ----- Original Message ----- > From: "Samuel Yip" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, July 23, 2002 7:01 AM > Subject: Web tools > > > Hi, > > I am new to perl and would like to use perl to do the following: > > 1. Prompt the user for a IP address. > 2. Ping the IP address from the web server and > 3. Print out the result to the user on the browser. > > Anyone knows how should I do it ? > > Thks > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]