Re: Conflict with Net::SSH::Perl and Tk?
- From: zentara <zentara@xxxxxxxxxxxxxx>
- Date: Thu, 04 Aug 2005 08:28:24 -0400
On Thu, 4 Aug 2005 08:44:59 +0000 (UTC), "Craig M. Votava"
<craig@xxxxxxxxxx> wrote:
>Folks-
>Maybe I should phrase the question better.
>Has anyone been able to successfully write
>a perl program that uses both Tk and Net::SSH::Perl
>and have it work?
>Thanks
>-Craig
Yes, I just wrote this and it runs on my linux machine.
You must have some sort of other problem not related
to Perl, probably in your global configuration of ssh.
#!/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 = "zpass";
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");
}
}
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
.
- References:
- Re: Conflict with Net::SSH::Perl and Tk?
- From: Craig M. Votava
- Re: Conflict with Net::SSH::Perl and Tk?
- Prev by Date: Re: Conflict with Net::SSH::Perl and Tk?
- Next by Date: Re: Setting Intial Directory
- Previous by thread: Re: Conflict with Net::SSH::Perl and Tk?
- Next by thread: Re: Conflict with Net::SSH::Perl and Tk?
- Index(es):