I don't see your comparison between your working snippet, and your failing sub. The failing sub dosn't resemble the working snippet at all. This snippet works on linux, you might try to substitute your working snippet and see if it goes.
#!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; use Tk; my $mw = MainWindow->new; my $text = $mw->Text(); $text->pack; $text->insert('end',"Net::SSH::Perl Test\n"); $mw->Button( -text => "SSH", -command => \&do_ssh )->pack; $mw->Button( -text => "Exit", -command => sub{exit} )->pack; MainLoop; sub do_ssh{ my $user = "z"; my $password = "ztest"; my @hosts = qw(localhost); foreach my $host (@hosts){ my $cmd = "/usr/bin/uptime"; my $ssh = Net::SSH::Perl->new( $host, port => 22 , protocol => 2, # debug => 1, ); $ssh->login($user,$password); my($out) = $ssh->cmd($cmd); my ($time,$uptime) = (split /\s+/,$out)[1,3]; chop $uptime; $text->insert('end', "$out\n"); $text->insert('end', "$host has been up $uptime\n"); } }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: SSH not working with TK by zentara
in thread SSH not working with TK by veeruch

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.