Skip to content

Instantly share code, notes, and snippets.

@szdytom
Created September 18, 2020 12:38
Show Gist options
  • Save szdytom/284e8183fdf96abc1a22fd796a21fa3b to your computer and use it in GitHub Desktop.
Save szdytom/284e8183fdf96abc1a22fd796a21fa3b to your computer and use it in GitHub Desktop.
retry until ok
#! /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