foreach $s (@servers) { my $ssh = Net::OpenSSH->new("$username\@$s", timeout=>30); $ssh->error and die "Unable to connect: " . $ssh->error; print "Connected to $s\n"; my $fh = $ssh->capture("df -k /home/ | tail -1") or die "Unable to run command\n"; my @df_arr = split(/\s+/, $fh); print "$s: Disk space /home/ = $df_arr[3] \n"; my $fh1 = $ssh->capture("svmon -G -O unit=GB | grep memory") or die "Unable to run command\n"; my @sv_arr = split(/\s+/, $fh1); print "$s: Free memory = $sv_arr[3] \n\n"; close $fh; undef $ssh; }