$ENV{HOME} = "/var/www/scripts/new"; use Net::OpenSSH; use Date::Simple ('date', 'today'); use warnings; my $ssh; $ssh = Net::OpenSSH->new('root@localhost', master_opts => [-o => "UserKnownHostsFile=/dev/null", -o => "StrictHostKeyChecking=no"], timeout => 10, ctl_dir => $ENV{HOME}) or $ssh->error and die "Couldn't establish SSH connection: ". $ssh->error; my $cmd = "ls -l"; my (@out, $err) = $ssh->capture({ timeout => 10 }, $cmd); $ssh->error; print $ssh->error; foreach (@out) { print $out[$i]. "
"; $i++; }