I'm trying to write a simple script that will ssh to and execute a command on a Cisco CallManager server. I can see that I'm authenticating and logging in to the CLI of the server, but I can't get the command to execute. I've tried multiple variations, but nothing is working.

I'm using strawbery perl on an XP machine, the CallManager server is running linux but I'm logging into a CLI (not the linux shell).


my $channel = $ssh->channel(); $channel->execute("show account"); my $output;<br> $channel->read($output,1028); print "output:\n $output\n";

The output that is returned;
output:
Command Line Interface is starting up, please wait ...

This line is what the CLI prints after you successfully login, so the authentication and creating the channel appears to be working.
I have tried ssh debug, and get the following;


libssh2_channel_open_ex(ss->session, pv_channel_type, len_channel_type, window_size, packet_size, ((void *)0) , 0 ) -> 0x15cc17c
Net::SSH2::Channel::read(size = 1028, ext = 0)
- read 55 bytes
- read 1 bytes
- read 2 bytes
- read 0 bytes
- read 58 total
output:
Command Line Interface is starting up, please wait ...


Net::SSH2::Channel::DESTROY
Net::SSH2::DESTROY object 0x9de1cc


I don't see any debug statement for the exec. I've also tried to create shell (with and without blocking(0/1) and then write the command, but get pretty much the same result.
I also know that this same script will work when connected to a Cisco IOS router/switch, so I know it's something with the CLI on the server. I'm just hoping there is a way to get it to work.

Any help would be appreciated, I don't know what else to try at this point.


-Aric

In reply to ssh2 channel/exec issue by armcinto

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.