getopt

Matthew Sacks ntwrkd at gmail.com
Tue Feb 10 20:12:46 EST 2009


if anyone can have a look at this code and offer suggestions i would
appreciate it.
i am forced to use getopt, so i cant use something good like optparse

passedArgs = sys.argv[1:]
optlist, args = getopt.getopt(str(passedArgs), ["connectPassword=",
"adminServerURL=", "action=", "targets=", "appDir="])


for some reason this does not work in assigning args to opts.


i want to take all of the command line options and assign them to strings

here is how i am currently going about it

for o,a in optlist:
	if o == "--connectPassword":
		connectPassword = a
		print "Connect password assigned as " + a
                continue
	elif o == "--adminServerURL":
		adminServerURL = a
		print "adminServerURL " + a
                continue
	else:
		print "No connection Arguments Specified"
		

TIV



More information about the Python-list mailing list