-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmypython.py
More file actions
31 lines (24 loc) · 703 Bytes
/
mypython.py
File metadata and controls
31 lines (24 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
import sys, getopt
"""https://www.tutorialspoint.com/python/python_command_line_arguments.htm"""
def main(argv):
directory = ''
try:
opts, args = getopt.getopt(argv,"hd:o:","dir=")
except getopt.GetoptError:
print ('1test.py -d <directory>' )
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print ('2test.py -d <directory>')
sys.exit()
elif opt in ("-d", "--dir"):
directory = arg
elif opt :
print('3test.py -d <directory>')
sys.exit(2)
print ('Directory is :', directory)
# print ('Output file is "', outputfile)
sys.exit()
if __name__ == "__main__":
main(sys.argv[1:])