Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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


In reply to null output on program by Nobby

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found