... my ($host, $user, $password, @cmds) = split ',', $line; my $ssh = Net::OpenSSH->new($host, user => $user, password => $password); if ($ssh->error) { print STDERR "Unable to log into remote host: ".$ssh->error; next; } print "HOST: $host\n\n" for my $cmd (@cmds) { my ($out, $err) = $ssh->capture2($cmd); print "CMD: $cmd\nRC: $?\nSTDOUT:\n$out\nSTDERR:\n$err\n\n\n"; }