Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I think you are confusing the concepts of "sessions" and "channels". In SSH2, multiple communication paths (channels) can be multiplexed through a single connection (session). The session is established by the new call, which establishes a TCP connection and performs the server identification key exchange. Once this is complete, additional channels can be established to perform tasks like port forwarding, transferring data or running an interactive shell.

The cmd method in this module creates a new channel each time it is invoked. This means that a new login shell is created, the user is authenticated, the command is run and the channel closed each time. The network connection remains for more channels. This looks like multiple connections.

If you want to run multiple commands within the same instance of a login shell, you need to use the shell method of the module, which "opens up an interactive shell on the remote machine and connects it to your STDIN." You will probably want to muck about with your file descriptors so that you can control what gets sent to STDIN programmatically (Expect, perhaps).


The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon

In reply to Re: which version Net::SSh::Perl support multiplecmd calls by idsfa
in thread which version Net::SSh::Perl support multiplecmd calls by veeruch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-25 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found