my $status = qx{ssh r01mn1 /etc/init.d/hadoop-0.20-mapreduce-jobtracker status | awk '{print $3}'}; print "$status is status of service"; if ( "$status" eq "stopped" ) { print " JOBTRACKER SERVICE is not running"; } output [root@r01mgt ~]# perl testscript.pl jobtracker is stopped is status of service SHELL COMMAND [root@r01mgt ~]# ssh r01mn1 /etc/init.d/hadoop-0.20-mapreduce-jobtracker status | awk '{print $3}' stopped