http://www.perlmonks.org?node_id=11148249

Nobby has asked for the wisdom of the Perl Monks concerning the following question:

Hey,

A mini summary, I have a script that has a hash ref of programs, this works normally if there is content output, but if there is an error by the program called, I get no output - including the error line.

For speed and brevity, in debugging I used traceroute as an example, if it looks up and performs the trace, it works but if it cant lookup, there is nothing., example...

sub main { print "Content-type: text/html\n\n"; print "<HTML> <HEAD>\n"; ....(omitted since this part works if real output print "</HEAD>\n"; open("runmain","$commands{$PROGRAM} $TARGET_HOST |"); while (<runmain>) { chomp $_; print "$_\n"; } print "</pre> </div></html>\n"; close ("runmain");
if I use traceroute to a hostname using -4 that resolves, traceroute output returns, however if I use -6 where it is known there is no ipv6 record, it just outputs nothing, there is no testing for null out put it should just print what it is given.

using traceroute on command line shows output

"aussiebb.com.au: No address associated with hostname Cannot handle "host" cmdline arg `aussiebb.com.au' on position 1 (argc + 2)
But the script returns
<pre> Content-type: text/html <HTML><HEAD> .... </HEAD> <BODY bgcolor=white text=#2554C7> </pre></div></html>
As far as the script is concerned, it should have no clue the above output is any less relevant to an actual traceroute return with a reply.

I guess i'm missing the obvious, but i've spent way too many hours trying to sort this out, commenting out line by line and multi lines trying to find where it is going wrong, thus I am am here asking for some perl spiritual learning :)

I have omitted a lot of the header and html code, that would be irrelevant, I might have missed one or two so if the html looks wrong, dont worry it is OK, given the above, Thanks