()
| 32 | |
| 33 | |
| 34 | def main(): |
| 35 | # Check the arguments passed to the script |
| 36 | if len(sys.argv) >= 2: |
| 37 | file_names = sys.argv[1:] |
| 38 | filteredfilenames_1 = list( |
| 39 | file_names |
| 40 | ) # To counter changing in the same list which you are iterating |
| 41 | filteredfilenames_2 = list(file_names) |
| 42 | # Iterate for each filename passed in command line argument |
| 43 | for filename in filteredfilenames_1: |
| 44 | if not os.path.isfile(filename): # Check the File exists |
| 45 | print("[-] " + filename + " does not exist.") |
| 46 | filteredfilenames_2.remove( |
| 47 | filename |
| 48 | ) # remove non existing files from fileNames list |
| 49 | continue |
| 50 | |
| 51 | # Check you can read the file |
| 52 | if not os.access(filename, os.R_OK): |
| 53 | print("[-] " + filename + " access denied") |
| 54 | # remove non readable fileNames |
| 55 | filteredfilenames_2.remove(filename) |
| 56 | continue |
| 57 | |
| 58 | # Read the content of each file that both exists and is readable |
| 59 | for filename in filteredfilenames_2: |
| 60 | # Display Message and read the file contents |
| 61 | print("[+] Reading from : " + filename) |
| 62 | readfile(filename) |
| 63 | |
| 64 | else: |
| 65 | usage() # Print usage if not all parameters passed/Checked |
| 66 | |
| 67 | |
| 68 | if __name__ == "__main__": |
no test coverage detected