use strict; use warnings; use Net::SSH::Perl; my $myssh; $SIG{ALRM} = sub { print STDERR "\nALARM\n"; $myssh->close; ### There is no close - what can I use? remcount($myssh); alarm 5; }; $myssh = Net::SSH::Perl->new( "MY.REMOTE.SERVER", protocol => 2 ); alarm 5; remcount($myssh); sub remcount { my $ssh = shift || die "missing ssh object"; $ssh->login("MYLOGIN", "MYPASSWORD") or die "Failed to login: $!\n"; # STDOUT handler... $ssh->register_handler('stdout', sub { my ($channel, $buffer) = @_; print STDERR "OUT BYTES: ", $buffer->bytes, "\n"; }); my $perlcmd = join('', ); my $cmd = "/bin/perl - -heartbeat "; print STDERR "REMOTE: $cmd\n"; my ($stdout, $stderr, $exit) = $ssh->cmd($cmd, $perlcmd); } __DATA__ use strict; use warnings; $|++; my $c=0; while(1) { print $c++; sleep 1; }