cmv has asked for the wisdom of the Perl Monks concerning the following question:
The attached program is driving me nuts! The idea here is to send the arguments for the ls command that the user selected (via checkbuttons), to the remote machine and display the resulting output.
The program (using the ARGS hash) fails in SSH with the error:
Tk::Error: input must be 8 bytes long at .../lib/site_perl/5.8.8/darwin/Crypt/DES.pm line 57.
If you comment out the ARGS line in hostls(), and uncomment the ARGS2 line, everything works fine.
Why? I can't figure this one out (grrrrr)...
Any help is appreciated!
Thanks
-Craig
Update: Added commented out help for windows users (same problem there too).
Update2: See Weird error with Cryprt::Blowfish and Crypt::DES for the person who did the real work, and Re: Strange Net::SSH::Perl and Tk Checkbutton Interaction!?! SOLVED!.
#!/usr/bin/perl require 5.004; use English; use strict; use Data::Dumper; use Tk; my %ARGS = ( l=>'-l', a=>'-a', s=>'-s'); my %ARGS2 = ( l=>'-l', a=>'-a', s=>'-s'); # Setup remote ssh connection... use Net::SSH::Perl; #use Net::SSH::W32Perl; # For windows my $host='remotehost'; my $ssh = Net::SSH::Perl->new($host) || die "Bad $host"; #my $ssh = Net::SSH::W32Perl->new($host) || die "Bad $host"; # For win +dows $ssh->login('remoteusr', 'remotepass') || die "Bad login"; # Create new window... my $top = MainWindow->new(-title=>'Options Test'); $top->minsize(470,225); my $f = $top->Frame()->pack; my $t = $top->Scrolled('Text')->pack; # Add checkbuttions in frame... for my $o (keys(%ARGS)) { $f->Checkbutton(-text=>$ARGS{$o}, -offvalue=>'', -onvalue=>$ARGS{$o}, -variable=>\$ARGS{$o}, -command=>\&hostls, )->pack(-side=>'left'); # Reset checkbutton variable (default is off)... $ARGS{$o}=''; } sub hostls { print STDERR Dumper(\%ARGS); my $args = join(' ', values(%ARGS)); # This fails #my $args = join(' ', values(%ARGS2)); # This works print STDERR "args=$args\n"; $t->delete('1.0', 'end'); my($stdout, $stderr, $exit) = $ssh->cmd("ls $args"); if($exit) { warn "Bad Command return\n$stderr"; return() }; $t->insert('end', $stdout); } MainLoop();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange Net::SSH::Perl and Tk Checkbutton Interaction!?!
by zentara (Cardinal) on Nov 09, 2007 at 13:41 UTC | |
by cmv (Chaplain) on Nov 09, 2007 at 14:22 UTC | |
|
Re: Strange Net::SSH::Perl and Tk Checkbutton Interaction!?!
by Anonymous Monk on Nov 09, 2007 at 08:58 UTC | |
|
Re: Strange Net::SSH::Perl and Tk Checkbutton Interaction!?!
by zentara (Cardinal) on Nov 09, 2007 at 17:17 UTC | |
|
Re: Strange Net::SSH::Perl and Tk Checkbutton Interaction!?! SOLVED!
by cmv (Chaplain) on Nov 09, 2007 at 18:27 UTC |