File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import sys # Import the Modules
2+ import os # Import the Modules
3+
4+ # Readfile Functions which open the file that is passed to the script
5+
6+ def readfile (filename ):
7+ print (filename )
8+ f = open (filename , 'r' )
9+ line = f .read ()
10+ print (line )
11+
12+
13+ def main ():
14+ filename = ''
15+ if len (sys .argv ) == 2 : # Check the arguments passed to the script
16+ filename = sys .argv [1 ] # The filename is the first argument
17+ if not os .path .isfile (filename ): # Check the File exists
18+ print ('[-] ' + filename + ' does not exist.' )
19+ exit (0 )
20+ if not os .access (filename , os .R_OK ): # Check you can read the file
21+ print ('[-] ' + filename + ' access denied' )
22+ exit (0 )
23+ else :
24+ print ('[-] Usage: ' + str (sys .argv [0 ]) + ' <filename>' ) # Print usage if not all parameters passed/Checked
25+ exit (0 )
26+ print ('[+] Reading from : ' + filename ) # Display Message and read the file contents
27+ readfile (filename )
28+
29+ if __name__ == '__main__' :
30+ main ()
You can’t perform that action at this time.
0 commit comments