I have trouble passing parameters to my script. Script launch command line : myscript.py -c Random I'm using getopt in my code (given down there) but this code is not looping through the arguments because later on the program the tested_company varible is not defined, where did I go wrong?
tested_company=None
try:
opts, args = getopt.getopt(sys.argv[1:], "hc:i", ['help', 'company', 'info']) #first argument ignored because zabbix giving it and being useless
except getopt.GetoptError as e:
print (e)
usage()
sys.exit(3)
if not opts:
#print ('No options supplied, only updating the database')
print("3")
sys.exit(3)
else:
for opt, arg in opts:
if opt in ('-h', '--help'):
usage()
sys.exit(0)
elif opt in ('-c', '--company'):
tested_company = arg
elif opt == '-i':
displayInfos=1
tested_companyto be? It's set toNoneon the very first line and then not reassigned at any point.