exit(0)
else:
print ("[-] Usage: " + str(sys.argv[0]) + " <filename>") // Print usage if not all parameters passed/Checked
exit(0)
print ("[+] Reading from : " + filename) // Display Message and read the file contents
readfile(filename)
After Change
def main():
if len(sys.argv) >= 2: // Check the arguments passed to the script
filenames = sys.argv[1:]
for filename in filenames: // Iterate for each filename passed in command line argument
if not os.path.isfile(filename): // Check the File exists
print ("[-] " + filename + " does not exist.")
filenames.remove(filename) //remove non existing files from filenames list
continue
if not os.access(filename, os.R_OK): // Check you can read the file
print ("[-] " + filename + " access denied")
filenames.remove(filename) // remove non readable filenames
continue
else:
usage() // Print usage if not all parameters passed/Checked
// Read the content of each file
for file in filenames:
print ("[+] Reading from : " + file) // Display Message and read the file contents
readfile(file)
if __name__ == "__main__":
main()