In the following Python snippet, why do arguments -h and –commandfile work but -c does not and further when I use -c, the error does not like sys.ext(2)
Here is the code:
#!/bin/python
import sys, getopt
try:
opts, args = getopt.getopt(sys.argv[1:],"hn:p:",["commandfile=","pkeyname="])
except getopt.GetoptError:
print('Error')
sys.ext(2)
# parse the args
for opt, arg in opts:
if opt == '-h':
print('endorse.py [-c,--commandfile] <parent commandfile> <parent keyname> [-k --pkeyname]')
sys.exit()
elif opt in ("-c", "--commandfile"):
print (arg)
elif opt in ("-k", "--pkeyname"):
pkeyname = arg
New contributor
Robert Moskowitz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1