You can execute commands on remote host using a Perl script using the Net::SSH::Perl module.
This module allows you to execute a command remotely and receive the STDOUT, STDERR, and exit status of that remote host command.
One big advantage of Net::SSH::Perl over other methods is that you can automate the login process, that way you can write fully automated perl scripts, no console interaction is required in order to authenticate in the remote machine.
#!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; use Data::Dumper; my $Host = "xxxxxx"; my $User = "xxxxxx"; my $Secret = "xxxxxx"; my $Path="/home/ree"; #Connect my $ssh = Net::SSH::Perl->new($Host); $ssh->login($User, $Secret); # Execute the command my($stdout, $stderr, $exit) = $ssh->cmd("ls -l $Path");
But if you use Net::OpenSSH module, check useful info from this node Problems with Net::OpenSSH
In reply to Re: help to deal with ssh connection
by vinoth.ree
in thread help to deal with ssh connection
by mitchreward
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |