http://www.perlmonks.org?node_id=136997

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am running a Perl script on a Win NT machine that retrieves web log files and data from servers outside of a firewall. I use an NT command line version of ssh and scp (called plink and pscp) from within the Perl script. The Perl script is run socksified under sockscap32. For some reason, I cannot capture (save to a variable) string data that results from a backticked or open/piped ssh call within the Perl script whenever it is run socksified. If it is not socksified, everything works fine. Here is an example of what I want to do:

myscript.pl -------- $data = `plink -ssh -pass mypass someuser@external.machine.com "ls -l +/home/someuser"`; # Do something with $data.... --------

In order to socksify the Perl script, I call
sc32.exe c:\Perl\bin\Perl.exe myscript.pl

from within a batch file. The ugly workaround I have involves writing the output of the ssh command on the remote machine to a file and then scp'ing the file to my local machine. Please help me find something elegant! Thank you,
Mark Hoefer
mark_hoefer@agilent.com