CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How to output ping to webpage ?

 



200120022003
New User

Dec 23, 2009, 12:57 AM

Post #1 of 2 (1992 views)
How to output ping to webpage ? Can't Post

My code:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
open FH, "ping www.1st.hk -c 5|" or die "Failed to open pipeline";
while(<FH>) {
$string .= $_."<br>";
}
close(FH);
print $string

When I run it from the command line interface. It success output:

Content-type: text/html

PING www.1st.hk (202.64.63.225) 56(84) bytes of data.
<br>64 bytes from mail.1st.hk (202.64.63.225): icmp_seq=1 ttl=64 time=0.111 ms
<br>64 bytes from mail.1st.hk (202.64.63.225): icmp_seq=2 ttl=64 time=0.051 ms
<br>64 bytes from mail.1st.hk (202.64.63.225): icmp_seq=3 ttl=64 time=0.062 ms
<br>64 bytes from mail.1st.hk (202.64.63.225): icmp_seq=4 ttl=64 time=0.052 ms
<br>64 bytes from mail.1st.hk (202.64.63.225): icmp_seq=5 ttl=64 time=0.042 ms
<br>
<br>--- www.1st.hk ping statistics ---
<br>5 packets transmitted, 5 received, 0% packet loss, time 3996ms
<br>rtt min/avg/max/mdev = 0.042/0.063/0.111/0.026 ms

But I run it from the web server with perl support, it cannot output anything.
I have tried 3 web server from different ISP. Anybody help me ?


FishMonger
Veteran / Moderator

Dec 23, 2009, 6:01 AM

Post #2 of 2 (1988 views)
Re: [200120022003] How to output ping to webpage ? [In reply to] Can't Post

Are you receiving an error page or a blank page?

Did you check the web sever error log?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives