uelordi01
5/24/2018 - 12:20 PM

CMD Parse argument

a simple python scritp which processes the command line arguments

import sys, getopt

def processArguments(argv):
    global inputfile
    global outputfile
    try:
        opts, args = getopt.getopt(argv,"i:o:", [])
    except getopt.GetoptError:
        print 'frompbtopbtxt.py -i <inputfile> -o <outputfile>'
    for opt, arg in opts:
        if opt == '-i':
            inputfile = arg
        if opt == '-o':
            outputfile = arg
            
if __name__ == "__main__":
    processArguments(sys.argv[1:])