
200120022003
New User
Dec 23, 2009, 12:57 AM
Post #1 of 2
(3738 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 ?
|