in reply to Unable to run command on Cisco switch
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
and it is the mode used by Net::SSH::Perl for its cmd method.$ ssh my.unix.box cat /etc/passwd
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unable to run command on Cisco switch
by 1wax (Novice) on Sep 01, 2009 at 07:09 UTC | |
by salva (Canon) on Sep 01, 2009 at 10:28 UTC | |
by 1wax (Novice) on Oct 08, 2009 at 13:06 UTC |