Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- system(@ssh) steals stdin
- Marc Girod
October 5, 2010, 9:36 am
rate this thread
Only partly a Perl question...
For some reason (don't ask...) I need to read data from stdin after
having invoked a program remotely, with ssh.
Surprise: there is nothing there...
$ cat rsdtin
my @ssh = qw(/usr/bin/ssh -q);
system(@ssh, qw(myhost /bin/date));
my @a = <>;
print "a: @a\n";
$ cat << eot | rstdin
Something I miss?
I thought of using Net::SSH::Perl, but I had some problems to install
it (or some dependency) in a way which would work on both Solaris 8
- Randal L. Schwartz
October 5, 2010, 12:05 pm
Re: system(@ssh) steals stdin
Marc> Only partly a Perl question...
Marc> For some reason (don't ask...) I need to read data from stdin after
Marc> having invoked a program remotely, with ssh.
Marc> Surprise: there is nothing there...
No surprise for me. In general, the child process started by system()
inherits Perl's stdin, stdout, and stderr. Your "ssh" is very likely
reading stdin in anticipation of sending it to the remote host.
If you tried the same trick with:
system "ssh myhost /bin/date </dev/null";
I'm sure you'd see a different output.
So it's not "system" stealing your input. It's ssh.
print "Just another Perl hacker,"; # the original
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion
- » FAQ 3.18 How can I free an array or hash so my program shrinks?
- — Next thread in » PERL Discussions
- » Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
- — Previous thread in » PERL Discussions