Created
June 20, 2020 03:34
-
-
Save NimishMishra/06c02f9cf4661042c5fc7ed297efa79a 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("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