Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by sojourner9 (Initiate)
on Mar 20, 2013 at 15:39 UTC ( #1024553=note: print w/ replies, xml ) Need Help??


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

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.


Comment on Re^6: SSH to remote subsystem (Net::OpenSSH?)
Re^7: SSH to remote subsystem (Net::OpenSSH?)
by alrighttheresham (Initiate) on Sep 10, 2014 at 13:39 UTC
    @sojourner9

    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.
        Thankyou @salva. Closing the out pipe worked, but adding a newline didnt. Code snippet below.
        ## SEND THE QUERY FOR THE CONFIG $message = qq~ <?xml version="1.0" encoding="UTF-8"?> <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> <get-config><source><running/></source></get-config> </rpc> ]]>]]>~; print $out $message; close $out; ## PRINT THE RESULTS while (<$in>) { print; last if $_ =~ m/\/nf:rpc-reply/; } close $in; waitpid( $pid, 0 ); exit;

        If I wanted to keep the $out pipe open so that further messages could be sent is there some sort of flush (I assume this is what you expected the newline to do) that could be used? I looked at the Net:OpenSSH docs in the open_ex section but dont see anything that suggests this can be done.

        If this is not possible should I close and recreate the open_ex for every req/res I send?

        Thanks for the prompt response, apologies if the questions are naive, perl newbie.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024553]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-12-27 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls