Created
September 18, 2020 12:38
-
-
Save szdytom/284e8183fdf96abc1a22fd796a21fa3b to your computer and use it in GitHub Desktop.
retry until ok
This file contains hidden or 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
#! /bin/python3 | |
import os | |
import sys | |
import time | |
os.system("touch /tmp/retry_sys_last_cmd_tmp_store") | |
last_cmd_file = open("/tmp/retry_sys_last_cmd_tmp_store", "r") | |
last_cmd = str(last_cmd_file.read()) | |
last_cmd_file.close() | |
cmd = input(("Command[%s]: " % (last_cmd))) | |
if cmd == "": | |
cmd = last_cmd | |
last_cmd_file = open("/tmp/retry_sys_last_cmd_tmp_store", "w") | |
last_cmd_file.write(cmd) | |
last_cmd_file.close() | |
while True: | |
if not os.system(cmd): | |
break | |
time.sleep(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment