Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Capturing data with backticks and sockscap

by Anonymous Monk
on Jan 08, 2002 at 03:35 UTC ( [id://136997]=perlquestion: print w/replies, xml ) Need Help??

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: -------- $data = `plink -ssh -pass mypass "ls -l +/home/someuser"`; # Do something with $data.... --------

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

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

Replies are listed 'Best First'.
Re: Capturing data with backticks and sockscap
by kwoff (Friar) on Jan 09, 2002 at 03:13 UTC
    Did you test that "socksification" (whatever that is) is what really is the cause? For example, by capturing output of a hello world script first unsocksified then socksified. Also maybe it is failing as a side-effect of trying to enable socksification (sorry, I like this word), not just the fact that it's socksed. For instance, you used a wrong flag or interpolated some variable on the shell command line. In particular, there is a `@' in your command-line that I have my eye on. Did you use the `-w' flag and `use strict'?
      The script runs fine when not socksified, although it will not connect to the external servers (because it is not socksified...). It will connect to any servers internal to our firewall and I can capture the output from a backticked ssh call.

      When I call the socksified Perl script from the command line, another window pops open. The script does not execute within the window from which I called it.

      Any more ideas?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://136997]
Approved by root
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-22 03:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found