Hi Everyone.
I tried the following to get input into optionparser from either a file
or command line.
The code below detects the passed file argument and prints the file
contents but the individual swithces do not get passed to option parser.
Doing a test print of options.qmanage r shows it unassigned.
Any ideas?
#
# Parse command line options and automatically build help/usage
# display
#
if len(sys.argv) == 2:
infile= open(sys.argv[1],"rb").read( )
print infile
parser=OptionPa rser( infile )
else:
parser = OptionParser()
parser.add_opti on("-m","--qmanager", dest="qmanager" ,
help="\t\tQueue Manager to inquire against"),
parser.add_opti on("-q","--queue", dest="queue",
help="\t\tQueue the message will be sent to"),
parser.add_opti on("-t","--to", dest="mto",
help="\t\taddre ss any mail messages will be sent to")
(options, args) = parser.parse_ar gs()
print options.qmanage r
I tried the following to get input into optionparser from either a file
or command line.
The code below detects the passed file argument and prints the file
contents but the individual swithces do not get passed to option parser.
Doing a test print of options.qmanage r shows it unassigned.
Any ideas?
#
# Parse command line options and automatically build help/usage
# display
#
if len(sys.argv) == 2:
infile= open(sys.argv[1],"rb").read( )
print infile
parser=OptionPa rser( infile )
else:
parser = OptionParser()
parser.add_opti on("-m","--qmanager", dest="qmanager" ,
help="\t\tQueue Manager to inquire against"),
parser.add_opti on("-q","--queue", dest="queue",
help="\t\tQueue the message will be sent to"),
parser.add_opti on("-t","--to", dest="mto",
help="\t\taddre ss any mail messages will be sent to")
(options, args) = parser.parse_ar gs()
print options.qmanage r
Comment