passing arguments like -JOB
John Leslie
johnleslie at madasafish.com
Thu Feb 10 08:13:16 EST 2005
I am porting a script from Korn Shell to python and want to pass named
parameters like -JOB 123456 -DIR mydir
I can get it to work passing --JOB and --DIR but not -JOB and -DIR
Any ideas?
Current code :
try:
options, xarguments = getopt.getopt(sys.argv[1:], '', ['JOB=',
'DIR=', 'ERR=', 'GRP=', 'TST=', 'JNM=', 'DAT=',])
except getopt.error:
print 'Error: You tried to use an unknown option'
sys.exit(1)
JOB = ''
for o,a in options[:]:
print 'here2'
print o
print a
if o == '--JOB':
JOB = a
print JOB
More information about the Python-list
mailing list