Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

which version Net::SSh::Perl support multiplecmd calls

by veeruch (Sexton)
on Jul 18, 2006 at 15:44 UTC ( #562045=perlquestion: print w/replies, xml ) Need Help??
veeruch has asked for the wisdom of the Perl Monks concerning the following question:

hi perlmonks
sorry iam giving lot of trouble.
iam wroking on windows environment ,iam using Net::SSH::W32Perl(version 0.05) and Net::SSH::Perl(version 1.23_01) Math::pari(version 2.010500).
But it is not supporting multiple cmd calls(after each cmd it is disconnecting).

so i have to use any new versions of above mentioned modules.
please any one can advise me. (my code support only SSH2 protocal)

  • Comment on which version Net::SSh::Perl support multiplecmd calls

Replies are listed 'Best First'.
Re: which version Net::SSh::Perl support multiplecmd calls
by idsfa (Vicar) on Jul 18, 2006 at 17:17 UTC

    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
      exactly wht u told right,I have given code.
      ssh->cmd("cd /test"); ssh->cmd("ls -lrt");
      it not showing previous command test directory files it is showing my directory files.
      is it happend in all the versions of windows (activestate perl)
      i couldn't understand ,how to use shell method running in multiple cmds in one instance ..can u explain briefly
      i saw document in that they specied ...
      use Term::ReadKey; ReadMode('raw'); $ssh->shell; ReadMode('restore');
      i tryed like this it is opening shell but not doing any thing and more over out close this shell...
Re: which version Net::SSh::Perl support multiplecmd calls
by jdtoronto (Prior) on Jul 18, 2006 at 16:04 UTC
    Net::SSH::Perl is at version 1.3 in the ActiveState repositories, and Math::Pari is at 2.010603 at the U-Winnipeg repository. Its pretty easy to check these things!


      my question is above i mentioned versions of all can support for multiple cmd calls?
        Read the doc's. Recent versions all support it, but 1.23 is pretty old, at least early 2003. In fact I think since SSH2 support was added the module can support multi-commands. But you dont say how you want to use them or what you are doing. THe documentation from at least 1.24 has eben rather explicit about multiple commands per connection and how to use them, the comments on that are immedaitely followed by the section on the $ssh->shell() method.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://562045]
Approved by Joost
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2018-06-18 00:23 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.