mercredi 21 septembre 2016

Why this python script is giving wrong output,using awk and comapring value in if block?

I want to get desktop notification whenever load is more than five,for that I have written this python script but it is giving opposite to expected

#!/usr/bin/python
import commands

a=commands.getoutput("cat /proc/loadavg | awk '{print $1}'")
float (a)
print a
if (a > 5.00):
    commands.getoutput('notify-send "Hello world!" ')
else:
    print "load looks fine!!"

Can someone rectify this ?

Aucun commentaire:

Enregistrer un commentaire