Dumb Q #1

Norm norm at norm.com
Tue Jan 28 04:55:07 CET 2003


I would like to open this unix passwd file and chang the GID of those who
have a GID of 200 to 199

This does everything except change fields[3] to 199

Thoughts?
Norm

##############################
import sys
try:
    file = open ("passwd.txt" , "r+")
except IOError, message:
    print >> sys.stderr," Can't open the file:", message
    sys.exit(1)

records = file.readlines()

for record in records:
    fields = record.split(':')
    if fields[3] == "200":
        print fields[0], " has a GID of 200"
        print "now changing it to 199"
        fields[3] = 199
file.close()




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----




More information about the Python-list mailing list