SSH Module: Accessing CLI box using SSH and not getting the return output??

Discussion in 'Perl Misc' started by Deepika, Nov 13, 2006.

  1. Deepika

    Deepika Guest

    Hi Everyone,

    I am trying to write a perl code to access and run few commands on a
    Secure CLI-Box using SSH module in Perl.After installing the Perl
    module with a lot of difficulty I am facing the following issue. I am
    able to log-into the box but I don't get any results back for the
    commands I am trying to run on the box.
    If I use the same perl code to log-into another linux machine and do
    an"ls" I get the result back with no problems at all. Here is the debug
    message while trying to access the CLI-box and running the commands.

    Any Help will be really appreciated. I have been struck at the same
    issue for about a month and my code is due soon and I have no clue how
    to fix it.

    [root@deepika-linux ~]# cd rnc
    [root@deepika-linux rnc]# perl ss.pl
    deepika-linux: Reading configuration data /root/.ssh/config
    deepika-linux: Reading configuration data /etc/ssh_config
    deepika-linux: Allocated local port 1023.
    deepika-linux: Connecting to xx.xx.xx.xx, port 22.
    deepika-linux: Remote version string: SSH-2.0-OpenSSH_3.5p1

    deepika-linux: Remote protocol version 2.0, remote software version
    OpenSSH_3.5p1
    deepika-linux: Net::SSH::perl Version 1.30, protocol version 2.0.
    deepika-linux: No compat match: OpenSSH_3.5p1.
    deepika-linux: Connection established.
    deepika-linux: Sent key-exchange init (KEXINIT), wait response.
    deepika-linux: Algorithms, c->s: 3des-cbc hmac-sha1 none
    deepika-linux: Algorithms, s->c: 3des-cbc hmac-sha1 none
    deepika-linux: Entering Diffie-Hellman Group 1 key exchange.
    deepika-linux: Sent DH public key, waiting for reply.
    deepika-linux: Received host key, type 'ssh-dss'.
    deepika-linux: Host 'xx.xx.xx.xx' is known and matches the host key.
    deepika-linux: Computing shared secret key.
    deepika-linux: Verifying server signature.
    deepika-linux: Waiting for NEWKEYS message.
    deepika-linux: Enabling incoming encryption/MAC/compression.
    deepika-linux: Send NEWKEYS, enable outgoing
    encryption/MAC/compression.
    deepika-linux: Sending request for user-authentication service.
    deepika-linux: Service accepted: ssh-userauth.
    deepika-linux: Trying empty user-authentication request.
    deepika-linux: Authentication methods that can continue: password.
    deepika-linux: Next method to try is password.
    deepika-linux: Trying password authentication.

    value of stdout = 1

    value of stderr =

    value of exitt =
    deepika-linux: channel 0: new [client-session]
    deepika-linux: Requesting channel_open for channel 0.
    deepika-linux: Entering interactive session.
    deepika-linux: Sending command: ?
    deepika-linux: Requesting service exec on channel 0.
    deepika-linux: channel 0: open confirm rwindow 0 rmax 32768

    value of stdout =
    value of stderr =
    value of exitt =
    [root@deepika-linux rnc]#

    Thanks and will wait for the response.
     
    Deepika, Nov 13, 2006
    #1
    1. Advertising

  2. Deepika

    J. Gleixner Guest

    Re: SSH Module: Accessing CLI box using SSH and not getting the returnoutput??

    Deepika wrote:
    > Hi Everyone,
    >
    > I am trying to write a perl code to access and run few commands on a
    > Secure CLI-Box using SSH module in Perl.After installing the Perl
    > module with a lot of difficulty I am facing the following issue. I am
    > able to log-into the box but I don't get any results back for the
    > commands I am trying to run on the box.
    > If I use the same perl code to log-into another linux machine and do
    > an"ls" I get the result back with no problems at all. Here is the debug
    > message while trying to access the CLI-box and running the commands.
    >
    > Any Help will be really appreciated. I have been struck at the same
    > issue for about a month and my code is due soon and I have no clue how
    > to fix it.


    Showing your code would help.

    First, run the ssh from the command line:

    ssh machine ls

    Does that work for both machines?
     
    J. Gleixner, Nov 13, 2006
    #2
    1. Advertising

  3. Deepika

    Deepika Guest

    Hi ,

    Thanks a lot for responding back. My code is really straightforward (as
    easy as it can get):

    use Net::SSH::perl;
    my $test = "xx.xx.xx.xx";
    %params = ("debug",true);
    my $sshtest = Net::SSH::perl->new($test,%params);
    my ($stdout, $stderr, $exit) = $sshtest->login("username","password");
    print "\n value of stdout = $stdout \n";
    print "\n value of stderr = $stderr \n";
    print "\n value of exitt = $exit \n";
    ($stdout, $stderr, $exit) = $sshtest->cmd("?");
    print "\n value of stdout = $stdout \n";
    print "value of stderr = $stderr \n";
    print "value of exitt = $exit \n";

    Also running an ssh from the command line works. When I do an:
    ssh user@ipaddress I actually enter the CLI session for the RNC(device
    I am trying to access,like entering a Cisco switch) and can now enter
    any commands.
    If I run my script to enter the same commands, I don't get a reply
    back.On the CLI manager I can't do an "ls" but I have tried various
    commands and none of them come back with any output.

    But as I mentioned if I use the same script above to access any other
    linux box and do an ls command I actually see the output back.


    J. Gleixner wrote:
    > Deepika wrote:
    > > Hi Everyone,
    > >
    > > I am trying to write a perl code to access and run few commands on a
    > > Secure CLI-Box using SSH module in Perl.After installing the Perl
    > > module with a lot of difficulty I am facing the following issue. I am
    > > able to log-into the box but I don't get any results back for the
    > > commands I am trying to run on the box.
    > > If I use the same perl code to log-into another linux machine and do
    > > an"ls" I get the result back with no problems at all. Here is the debug
    > > message while trying to access the CLI-box and running the commands.
    > >
    > > Any Help will be really appreciated. I have been struck at the same
    > > issue for about a month and my code is due soon and I have no clue how
    > > to fix it.

    >
    > Showing your code would help.
    >
    > First, run the ssh from the command line:
    >
    > ssh machine ls
    >
    > Does that work for both machines?
     
    Deepika, Nov 14, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gnarlodious
    Replies:
    4
    Views:
    17,704
    elizas
    May 5, 2010
  2. Martin Honnen

    Re: Using AltovaXML with C++/CLI

    Martin Honnen, Dec 27, 2008, in forum: XML
    Replies:
    0
    Views:
    510
    Martin Honnen
    Dec 27, 2008
  3. Hedley
    Replies:
    1
    Views:
    1,537
    Ram245
    Nov 8, 2013
  4. David Landrith
    Replies:
    0
    Views:
    127
    David Landrith
    Jul 29, 2003
  5. jrpfinch
    Replies:
    0
    Views:
    157
    jrpfinch
    May 9, 2007
Loading...

Share This Page