netstat -an | grep x.x.x.x tcp 0 0 x.x.x.x:55942 x.x.x.x:22 ESTABLISHED unix 2 [ ACC ] STREAM LISTENING 7356830 /home/cstrong/.libnet-openssh-perl/root-10.224.138.142-26229-724671 #### #!/usr/bin/perl use Net::OpenSSH; $ip="x.x.x.x"; $user="xx"; $pass="xx"; ($ssh)=&connect_ssh($ip, $user, $pass); @arry = $ssh->capture("ps -ef"); while (@arry) { $line=shift @arry; print "MATCH1 $line"; } @arry = $ssh->capture("ps -ef"); while (@arry) { $line=shift @arry; print "MATCH2 $line"; } sub connect_ssh { my $ip = shift; my $user = shift; my $pass = shift; my $ssh = Net::OpenSSH->new( $ip, strict_mode => '0', user => $user, password => $pass, timeout => '60'); return ($ssh); }