I am a newbie in Perl Scripting. I am working on code in which I have to get CPU utilization. I am trying to run a command and then get the output in a variable. But when I try to print the variable I get nothing on the scree.
Command works fine in the terminal and gives me an output. ( I am using Eclipse ).
my $CPUusageOP;
$CPUusageOP = qx(top -b n 2 -d 0.01 | grep 'Cpu(s)' | tail -n 1 | gawk '{print $2+$4+$6}');
print "O/P of top command ", $CPUusageOP;
Output I get is :
O/P of top command
Expected output :
O/P of top command 31.4
Thanks.