Why this python script is giving wrong output,using awk and comapring value in if block?
<p>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</p>

<pre><code>#!/usr/bin/python
import commands

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

<p>Can someone rectify this ?</p>

<p>Getting the first token from a file is easy to do natively in Python.  There is no reason to call <code>awk</code> (let alone then <a href="http://www.iki.fi/era/unix/award.html" rel="nofollow"><code>cat</code> and <code>awk</code></a>) and wastefully create a subprocess chain for this simple thing.</p>

<pre><code>#!/usr/bin/env python
import commands
with open('/proc/loadavg') as load:
    a = float(load.readline().split()[0])
if a &gt; 5.00:
    commands.getoutput('notify-send "Hello world!"')
else:
    print("load looks fine!!")
</code></pre>

python linux shell if-statement