Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: null output on program

by atcroft (Abbot)
on Nov 19, 2022 at 01:39 UTC ( [id://11148251]=note: print w/replies, xml ) Need Help??


in reply to null output on program

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148251]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-28 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found