Breaking the barrier of a broken paradigm... part 1
john s.
john.jython at gmail.com
Tue Mar 25 06:44:59 EDT 2008
On Mar 24, 9:39 pm, "Ryan Ginstrom" <softw... at ginstrom.com> wrote:
> > 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(":")
^----- Ok this one here we are taking a string spliting it
into to variables...
user gets one (the first) and _pwd gets to hold the
"leftovers"?
> user_home = os.path.join("/expirt/home", user)
>
> > try:
> > os.makedirs('usrHome' )
> > except Exception, e:
> > print e
>
> if os.path.exists(user_home):
^----- are(n't) exists and os.path.isadir
interchangable?
*nods in Bryan O. direction*
> 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