Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Short form: Were I to make a semi-educated guess, it would be this: You need to capture the output of both STDOUT and STDERR.

Long form:
In *nix environments, many programs write their normal output to Standard Output (known as STDOUT), but write warning and error messages to Standard Error (known as STDERR). When your 'traceroute' command fails, the output from the error is written on STDERR, as illustrated by the following (STDOUT is file handle 1, STDERR file handle 2):

# Test to an entry that does not exist in DNS $ traceroute foo.aussiebb.com.au foo.aussiebb.com.au: Name or service not known Cannot handle "host" cmdline arg `foo.aussiebb.com.au' on position 1 ( +argc 1) $ # Same test, with STDOUT directed to /dev/null (discard output to STDO +UT) $ traceroute foo.aussiebb.com.au 1>/dev/null foo.aussiebb.com.au: Name or service not known Cannot handle "host" cmdline arg `foo.aussiebb.com.au' on position 1 ( +argc 1) $ # Same test, with STDERR directed to /dev/null (discard output to STDE +RR) $ traceroute foo.aussiebb.com.au 2>/dev/null $

If you are using a *nix-y OS, you may be able to get what you expect by simply appending the string '2>&1' to the command (which in many shells redirects anything sent to STDERR to STDOUT). Alternately, if you use one of the IPC::Run* modules you may be able to capture the error output explicitly.

All that to say that in your example the 'open' line would be changed to read: open("runmain","$commands{$PROGRAM} $TARGET_HOST 2>&1 |"); (Although you might want to consider checking if the open failed or not.)

Hope that helps.


In reply to Re: null output on program by atcroft
in thread 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 exploiting the Monastery: (5)
As of 2024-03-29 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found