View Single Post
Moderator | Posts: 6,215 | Thanked: 6,400 times | Joined on Nov 2011
#563
Originally Posted by Win7Mac View Post
True, works without -n too.

Also I'm using this script to show uptime in decimal numbers:
Code:
#!/usr/bin/python
# Show Device Uptime in decimal days

sc = u"\u2622"
seconds = int(float(open('/proc/uptime').read().split()[0]))
print 'up: '+("%.1f" % (float(seconds)/float(60*60*24))).replace('.', ',')+' d'+' '+sc.encode('utf-8')
Now I want it to show the after decimal point only when upime is <10 days.
So that it would print "9,9 days" and "10 days".
Could someone put that rule to the script please?
I haven't learned python yet but a fast-and-dirty similar sh script:

Code:
#!/bin/sh
#uptime

days=$(cat /proc/uptime | awk '{print $1}')
days2=`dc $days 86400 / p | cut -c1-4`
days3=`dc $days 86400 / p | awk -F"." '{print $1}'`

if [ $days3 -lt 10 ]
then
echo -n -e up\: $days2 
else 
echo -n -e up\: $days3
fi
echo -n -e \ "\xe2\x98\xA2"
It requires dc to work but IIRC dc is by default present...

dc from Harmattan SDK or here...

Last edited by thedead1440; 2013-01-27 at 16:18.
 

The Following User Says Thank You to thedead1440 For This Useful Post: