Partition names with Python
John Hunter
jdhunter at ace.bsd.uchicago.edu
Tue Jul 1 09:45:41 EDT 2003
>>>>> "Andrew" == Andrew Bennetts <andrew-pythonlist at puzzling.org> writes:
Andrew> Or simply reading /etc/mtab or perhaps /proc/mounts (this
Andrew> one is linux-specific, I think), rather than spawning a
Andrew> process.
Good advice! This seems to do it:
import os
for line in file('/etc/mtab'):
if line.find('/dev/') !=0: continue
columns = line.split()
print columns[0].split('/')[-1]
JDH
More information about the Python-list
mailing list