November 8th, 2004, 01:56 PM
Just follow the example and you should be able to see what's going on; simply I've split the commands output then only printed the part you wanted (-2). There are of course other ways to do this, this is just my preference
>>> import commands
>>> info = commands.getoutput('df /var')
'Filesystem 512-blocks Used Avail Capacity Mounted on\n/dev/disk0s3 116948016 14353216 102082800 12% /'
['Filesystem', '512-blocks', 'Used', 'Avail', 'Capacity', 'Mounted', 'on', '/dev/disk0s3', '116948016', '14353216', '102082800', '12%', '/']
>>> data = info.split()
>>> print data[-2]
programming language development: www.netytan.com – Hula
Last edited by netytan : November 8th, 2004 at 02:01 PM.