This assumes you have installed the Net::SSH::Perl module on your system.
Create an SSH connection to another host.
#!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; $host = "your_hostname"; $user = "your_username"; $pass = "your_password"; $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); ($var1) = $ssh->cmd("type the commands you want to run on the remote host here"); print $var1;
Running the script will produce the result of the command you ran on the remote host. For example, if you ran the "hostname" command on the remote host, the result would be the hostname.
When getting data from another server over SSH, the data will be stored in a variable. Split can be used to convert the variable into an array.