import getopt env = None password = None list = None opts, args = getopt.getopt(sys.argv[1:], "e:p:l:") for opt, arg in opts: print opt, arg if opt in "-e": env = arg if opt in "-p": password = arg if opt in "-l": list = arg print "env", env print "password", password print "list", list
java weblogic.WLST testgetopts.py -e pippo -l cino,cano
the output is:
-e pippo
-l cino,cano
env pippo
password None
list cino,cano
Later, you can check if an argument has been passed by
if password is None: print "missing argument password"
No comments:
Post a Comment