Breaking the barrier of a broken paradigm... part 1
Ryan Ginstrom
software at ginstrom.com
Mon Mar 24 21:39:44 EDT 2008
> On Behalf Of john s.
> import os, sys, string, copy, getopt, linecache
> from traceback import format_exception
>
> #The file we read in...
> fileHandle = "/etc/passwd"
> srcFile = open(fileHandle,'r')
> srcList = srcFile.readlines()
>
> #yah, a for loop that "iterates" through the file of "lines"
> for i in srcList:
> strUsr = string.split(i,":")
> theUsr = strUsr[0]
> usrHome = "/expirt/home/",theUsr,"/"
> usrHome = ''.join(usrHome)
How about for starters:
import os
for line in open("/etc/passwd"):
user, _pwd = line.split(":")
user_home = os.path.join("/expirt/home", user)
> try:
> os.makedirs('usrHome' )
> except Exception, e:
> print e
if os.path.exists(user_home):
print "User Home dir exists, checking and fixing permissions."
else:
print "Do other stuff"
Regards,
Ryan Ginstrom
More information about the Python-list
mailing list