If you just need to connect and run a script, consider using the command-line SSH via the Expect module. I've found that quite helpful. Something like:
use strict; use warnings; use Expect; my $login = "xxx"; my $pass = "xxx2"; my $test_dir = "/foo/bar/"; my $cmd = "if [ -d $test_dir ]; then echo DIR_EXIST:1; else echo DIR_E +XIST:0; fi"; my $timeout = 30; my $ex = Expect->new('ssh','-t',"$login\@hostname",$cmd); # the -t fo +rces TTY allocation, helpful for Expect! $ex->expect( $timeout, [ qr/password:\s*$/i => sub { $ex->send($pass,"\n"); return 1; } ] +, [ timeout => sub { warn "Timeout waiting for password prompt"; ret +urn 1; } ], ); $ex->expect ( $timeout, [ qr/DIR_EXIST:\d/ => sub { print "Result: ",$ex->match(); } ], );
I've used this approach to do remote password-resets, user deletes, software installation, &c. It's a bit more code, but you get a lot more control.
In reply to Re: Net::SSH::Perl and SSH protocols
by radiantmatrix
in thread Net::SSH::Perl and SSH protocols
by xorl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |