Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^5: SSH to remote subsystem (Net::OpenSSH?)

by salva (Abbot)
on Mar 20, 2013 at 15:24 UTC ( #1024542=note: print w/replies, xml ) Need Help??

in reply to Re^4: SSH to remote subsystem (Net::OpenSSH?)
in thread SSH to remote subsystem (Net::OpenSSH?)

You have to close the input and output pipes before calling waitpid:
... close $in; close $out; waitpid($pid, 0);

Replies are listed 'Best First'.
Re^6: SSH to remote subsystem (Net::OpenSSH?)
by sojourner9 (Initiate) on Mar 20, 2013 at 15:39 UTC

    That got it! Thanks!

    It's working perfectly now using the large block of code posted above with the addition of those two closes.

    The rest of this will just be the grunt work of turning the replies into useable formats for other tools.


      I'm using your code snippet to talk to a NETCONF Agent. The problem I'm having is that the response is only showing the hello response, nothing else. For my second query I have sent a get-config and can see that processed on the Agent and a log entry confirming that it sent the response.

      Would it be possible for you to append your mainline is case something has got missed?

      Below is the merged content from the thread above that I'm using.

      ... ## PRINT THE RESULTS while (<$in>) { print; last if $_ =~ m/\/nf:rpc-reply/; }; close $in; close $out; waitpid($pid, 0); exit;
        Try closing $out before reading from $in or adding a new line after the last end-of-command marker.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024542]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-07-20 20:59 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (441 votes). Check out past polls.