Skip to content

Instantly share code, notes, and snippets.

@NimishMishra
Created June 20, 2020 03:10
Show Gist options
  • Save NimishMishra/6298de14cc6ccbc59065a62a0e654ff9 to your computer and use it in GitHub Desktop.
Save NimishMishra/6298de14cc6ccbc59065a62a0e654ff9 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:
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