Its been about a week since my last blog…coz we are presently not studying anything new in the summer training. We are just practising programs on python.
So, kushal gave us some very cool programs to do like to a program which prints the same output as the mount command.
This was my version (I used fedora disto) :
#!/usr/bin/env python f=open("/proc/mounts") f.readline() for s in f: s=s.replace(' 0 0\n','') s=s.split() s.insert(1,'on') s.insert(3,'type') s='('+s a=s.split(',') del s[-1] s=' '.join(s) print s, if a=='seclabel': c=1 for j in a: if (j=='n' or j=='r') and j!='r' : c=c+1 a.remove('seclabel') a.insert(c,'seclabel') a=','.join(a) print a + ')' f.close()
I considered arranging the string ‘seclabel’ or else program would have been smaller.