in reply to Re: Retrieving status data from a device with SSH 2 using Perl
in thread Retrieving status data from a device with SSH 2 using Perl

Yes... probably there are different modes. Is there a way to make the server give the answers to the commands as if they were written using the shell?

For this solution you suggest with Expect, should I use it directly with the shell executing ssh from the Perl script? Because I guess that if I use Expect with the Net::OpenSSH commands, I have to work with the same incomplete answer as if I were using the commands directly.

Thanks again!

PS: Salva? Betanzos? Super López? I guess I'm not the only Spaniard here!

Replies are listed 'Best First'.
Re^3: Retrieving status data from a device with SSH 2 using Perl
by salva (Canon) on Feb 17, 2010 at 13:35 UTC
    Because I guess that if I use Expect with the Net::OpenSSH commands, I have to work with the same incomplete answer as if I were using the commands directly.

    You can use Net::OpenSSH to establish the connection to the remote machine and then run an interactive shell managed with Expect as follows:

    my ($pty, $pid) = $ssh->open2pty() # and empty command line invokes a +shell! or die "unable to run remote shell"; my $expect = Expect->init($pty); $expect-> ...
    Though, if that is all you need to do in the remote server, using Expect alone will be almost the same, the only difference is that you will have to take care of authentication also.
    PS: Salva? Betanzos? Super López? I guess I'm not the only Spaniard here!

    No, you are not, where are you from?

      Ok, then both are valid for me :) Now it's time to deal with Expect, but my first approaches look good.

      No, you are not, where are you from?

      Que sí, medio madrileño medio toledano, pa'servirle...

      Thanks again

        Que sí, medio madrileño medio toledano, pa'servirle...
        Then, let me invite you to the social meeting of the Madrid Perl Mongers we are having tomorrow!