SPUG: Reg SSH Packet

Andrew Sweger andrew at sweger.net
Thu Mar 17 10:53:18 PST 2005

On Thu, 17 Mar 2005, Reddy V, Ravinder (Ravinder) wrote:

>  The above perl script should execute the command "ls" remote machine and
> should display on the local shell. 
> Can anyone please let me know what is the problem in the above script. 

Can you tell us what it _is_ doing and how it's not what you expect?

> =======================
>  #! /usr/bin/perl -w
> use Net::SSH::Perl;
> use Net::SSH::Perl::Packet;
> use Net::SSH::Perl::Constants qw( :msg PROTOCOL_SSH1 );

Not many folks use ssh1 anymore. Are you sure the remote host supports
this protocol?

> use IO::Select;
> eval {
>     my $ssh = Net::SSH::Perl->new("",port=>22);

Are you sure this is the correct address and port for the remote host?
It's clearly an address in the Lucent network space.

Don't you need to $ssh->login()?

>     #my($stdout, $stderr, $exit) = $ssh->cmd("ls");
>     my $pack = Net::SSH::Perl::Packet->new( $ssh, type => SSH_CMSG_USER ); 
>     $pack->put_str("ls");
>     $pack->send;
>     $pack = Net::SSH::Perl::Packet->read_expect($ssh,2 );     
>     print $pack->get_str;
>     }; 
>         if ($@) {
>      print "$@";
>         }

I still haven't used the Net::SSH::Perl packages. But do you really need
to use the packet layer interface? For command line driven stuff, wouldn't
the Net::SSH::Perl module be enough with $ssh->cmd()?

Andrew B. Sweger -- The great thing about multitasking is that several
                                things can go wrong at once.

More information about the spug-list mailing list