Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

terminal exercises

Views: 2497
1
#! /usr/bin/python3
2
3
import sys
4
print("This is the name of the script: ", sys.argv[0])
5
print("Number of arguments: ", len(sys.argv))
6
print("The arguments are: " , str(sys.argv))
7
8
if not len(sys.argv)==2:
9
print("usage: ./cat.py filename")
10
exit()
11
12
try:
13
file_h = open(sys.argv[1],"r")
14
file_content = file_h.read()
15
print(file_content)
16
except:
17
print("Does that file really exist?")
18