Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The SSH protocol allows for two modes of operation:

The first one is the interactive mode, designed to "talk" with humans, that just launches a shell and attaches it to the SSH channel, that is expected to be attached to the user console in the computer running the SSH client.

The second mode, allows to run independent commands. When it is used, the SSH server runs the given command attaching its IO streams to the SSH channel. It is what you get, for instance, when you run

$ ssh my.unix.box cat /etc/passwd
and it is the mode used by Net::SSH::Perl for its cmd method.

Unfortunately, some servers (as probably the one you are using) do not support this mode and unconditional launch a new shell for every new channel created.

To work-around that, you have to talk directly to the shell, and for that Expect is your best option, or even Net::SSH::Expect that is a wrapper around Expect specifically designed to talk to SSH servers.

... but Expect does not work on Windows, well, it doesn't work with ActiveState Perl (or AFAIK, with Strawberry Perl), but it works with Cygwin Perl.

Probably, Net::SSH::Perl (or Net::SSH2) have low level methods allowing to handle an interactive conversation with a channel, but it's not going to be as easy as with Expect!

update: and BTW, Net::SSH::W32Perl was a hack to make old versions of Net::SSH::Perl work under Windows. AFAIK, its logic was incorporated into the main module and so it shouldn't be used anymore.


In reply to Re: Unable to run command on Cisco switch by salva
in thread Unable to run command on Cisco switch by 1wax

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 examining the Monastery: (4)
As of 2024-04-25 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found