in reply to assign open2 output to variable
That output is being sent to STDERR rather than STDOUT. You can easily merge the two using open3 while still avoiding to spawn a needless shell.
use IPC::Open3 qw( open3 ); my @command = qw( plink -ssh -pw passwd user@host -batch exit ); open3(\*CIN, \*COUT, \*COUT, @command); close CIN; my $xs = <COUT>; print "the output is :".$xs; close COUT;
Note that the order of open3's first two argument is different than open2's.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: assign open2 output to variable
by adrivez (Initiate) on Mar 29, 2014 at 02:09 UTC | |
by ikegami (Patriarch) on Mar 31, 2014 at 16:05 UTC |