lamiastella

python

Sep 29th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys, getopt
  4.  
  5. def main(argv):
  6. inputfile = ''
  7. outputfile = ''
  8. try:
  9. opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
  10. except getopt.GetoptError:
  11. print 'test.py -i <inputfile> -o <outputfile>'
  12. sys.exit(2)
  13. for opt, arg in opts:
  14. if opt == '-h':
  15. print 'test.py -i <inputfile> -o <outputfile>'
  16. sys.exit()
  17. elif opt in ("-i", "--ifile"):
  18. inputfile = arg
  19. elif opt in ("-o", "--ofile"):
  20. outputfile = arg
  21. print 'Input file is "', inputfile
  22. print 'Output file is "', outputfile
  23.  
  24. if __name__ == "__main__":
  25. main(sys.argv[1:])
Add Comment
Please, Sign In to add comment