#!/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: