Folks-

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();

In reply to Strange Net::SSH::Perl and Tk Checkbutton Interaction!?! SOLVED by cmv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.