neptuna has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a script that I have been running successfully on perl 5.6.1. It uses Net::SSH to send the code of another perl script to a remote host. I tried to move the script(s) to a new box running 5.8 and it errors out while trying to run the cmd method on the command string passed to it. Here is the error (that is very misleading) and the relevant parts of the script. For some reason if I try to feed a `cat` to the $cmd string, it does not work
use Net::SSH::Perl; $host = "somehost"; my $ssh = Net::SSH::Perl->new($host, protocol => '2', debug => 1, privileged => 0); # THIS FAILS, WORKED FINE BEFORE #my $cmd = "perl -e '".`cat ./cm-unix.pl`."'"; # THIS IS JUST A ONE LINE FILE with 'ls-l' THAT FAILS my $cmd = `cat GO`; # WORKS FINE my $cmd = 'cd /tmp; ls -l'; $ssh->login( $ENV{USER} ); my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
ERROR: input must be 8 bytes long at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Crypt/DES.pm line 57.
---
I have tried google and searching throug the archives but not have been able to find out why this happens Thanks for any help, Jim

Replies are listed 'Best First'.
Re: Net:SSH:Perl Bug?
by syphilis (Archbishop) on Sep 08, 2006 at 00:05 UTC
    ERROR: input must be 8 bytes long at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Crypt/DES.pm line 57.

    For me, DES.pm contains:
    52: sub encrypt 53: { 54: usage("encrypt data[8 bytes]") unless @_ == 2; 55: 56: my ($self,$data) = @_; 57: return Crypt::DES::crypt($data, $data, $self->{'ks'}, 1); 58: }

    It's that first argument to Crypt::DES::crypt() that needs to be 8 bytes long. I would try inserting a print statement in there - on both the successful and the failing machines. Hopefully, the difference in the output will enable you to determine the cause of the problem (and the solution). Try changing that code to (untested):
    sub encrypt { usage("encrypt data[8 bytes]") unless @_ == 2; my ($self,$data) = @_; print "\nMY DEBUG: ", length($data), " ", $data, "\n\n"; return Crypt::DES::crypt($data, $data, $self->{'ks'}, 1); }


    Cheers,
    Rob
      Thanks Rob, I will give it a try