import sys
import os
import getopt
for arg in sys.argv:
print arg
def usage():
print """ usage: check_load_test2 [--help] [-m | mode 1|2|3] [-w | --warning level] [-c | --critical level]
mode:1 -last minute ; 2- last 5 minutes; 3 -last 15minutes
Warning defaults to 2.0
Critical level defaults to 5.0 """
# sys.exit(3)
def main(argv):
grammer="person.xml"
try:
opts,args=getopt.getopt(argv,"hg:d",["help","grammar="])
print opts
print "args:",args
except getopt.GetoptError:
usage()
sys.exit(2)
for opt,arg in opts:
if opt in ("-h","--help"):
usage()
sys.exit()
if opt== '-d':
global _debug
_debug=1
elif opt in ("-g","--grammar"):
# source="".join(args)
print arg
if __name__== "__main__":
main(sys.argv[1:])
#python test_get_opt.py -d --grammar=abc.xml
# python test_get_opt.py -d --grammar=abc.xml
~
阅读(1244) | 评论(0) | 转发(0) |