forked from AbeTavarez/Python_DevOps_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsys_args.py
More file actions
23 lines (15 loc) Β· 735 Bytes
/
Copy pathsys_args.py
File metadata and controls
23 lines (15 loc) Β· 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
# *********** First command line tool ************
# import the system module
import sys
# we can pass a List of arguments to our script when we're executing it from the command line or terminal
# This Argument List is called 'argv' or 'arguments vertor'
# Let's se this in action:
if __name__ == "__main__":
print(f'The first argument -> : {sys.argv[0]}')
print(f'The second argument -> : {sys.argv[1]}')
print(f'The third argument -> : {sys.argv[2]}')
print(f'The fourth argument -> : {sys.argv[3]}')
# * Now run the script from the command line with the fillowing arguments:
# * Rememmber you need to be in the same directory the script is located
# ./sys_args.py 'arg1' 'arg2' 'arg3'