Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Problems with open3

by salva (Canon)
on Oct 15, 2014 at 10:54 UTC ( [id://1103900]=note: print w/replies, xml ) Need Help??


in reply to Problems with open3

If you just want to capture the output from some external program, you can use backquotes:
my $ssh_version = `ssh -V`; chomp $ssh_version; printf "[%s]\n", $ssh_version;

If you really need IPC::Open3, you should know that it is a quite complex module under the hood. In my experience, one of the best ways to troubleshoot it is to use strace or some similar tool.

Also, there are several alternative modules on CPAN that may work better for you.

Replies are listed 'Best First'.
Re^2: Problems with open3
by RonW (Parson) on Oct 15, 2014 at 17:01 UTC

    To capture STDERR with backquotes, use:

    $output = `cmd 2>&1 1>/dev/null`;

    If you want both, omit redirecting STDOUT to /dev/null:

    $output = `cmd 2>&1`;

    However, it is generally safer to use open3.

Log In?
Username:
Password:

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

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

    No recent polls found