For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > September 2006 > Net:SSH:Perl error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Net:SSH:Perl error
Jim

2006-09-06, 9:57 pm

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








Tom Phoenix

2006-09-06, 9:57 pm

On 9/6/06, Jim <jkipp5@comcast.net> wrote:

> 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 suspect that this is related to Unicode: A string of eight
characters isn't necessarily eight bytes anymore.

If you can track down the source of the string being used on that
line, you may be able to use pack() to limit it to eight bytes, or
perhaps unpack() to break it into eight-byte chunks, whichever is
appropriate. Or you could re-install an older version of perl, since
that works for you, and use that until the bugs are all found and
fixed.

You can report the bug (or search previous reports) via rt.cpan.org:

http://rt.cpan.org

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training
jkipp5@comcast.net

2006-09-07, 7:57 am


Tom Phoenix wrote:
> On 9/6/06, Jim <jkipp5@comcast.net> wrote:
>
>
> I suspect that this is related to Unicode: A string of eight
> characters isn't necessarily eight bytes anymore.
>
> If you can track down the source of the string being used on that
> line, you may be able to use pack() to limit it to eight bytes, or
> perhaps unpack() to break it into eight-byte chunks, whichever is
> appropriate. Or you could re-install an older version of perl, since
> that works for you, and use that until the bugs are all found and
> fixed.
>
> You can report the bug (or search previous reports) via rt.cpan.org:
>
> http://rt.cpan.org
>
> Hope this helps!
>


Thanks Tom
The problem does not seem to be with the length of the string. It
seems to be a problem with using `cat` to populate the $cmd variable.

for instance, in the code you see I cat the file GO which contains the
the line:
cd /tmp;ls -l
my $cmd = `cat GO`;

now if i just put a regular string into $cmd it works fine:
my $cmd = 'cd /tmp; ls -l';

jkipp5@comcast.net

2006-09-07, 7:57 am


Tom Phoenix wrote:
> On 9/6/06, Jim <jkipp5@comcast.net> wrote:
>
>
> I suspect that this is related to Unicode: A string of eight
> characters isn't necessarily eight bytes anymore.
>
> If you can track down the source of the string being used on that
> line, you may be able to use pack() to limit it to eight bytes, or
> perhaps unpack() to break it into eight-byte chunks, whichever is
> appropriate. Or you could re-install an older version of perl, since
> that works for you, and use that until the bugs are all found and
> fixed.
>
> You can report the bug (or search previous reports) via rt.cpan.org:
>
> http://rt.cpan.org
>
> Hope this helps!
>


Thanks Tom
The problem does not seem to be with the length of the string. It
seems to be a problem with using `cat` to populate the $cmd variable.

for instance, in the code you see I cat the file GO which contains the
the line:
cd /tmp;ls -l
my $cmd = `cat GO`;

now if i just put a regular string into $cmd it works fine:
my $cmd = 'cd /tmp; ls -l';

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com