Skip to content

Instantly share code, notes, and snippets.

@chadselph
Created January 11, 2017 01:44
Show Gist options
  • Save chadselph/b62c421a1f974b255dfd384e09f1f330 to your computer and use it in GitHub Desktop.
Save chadselph/b62c421a1f974b255dfd384e09f1f330 to your computer and use it in GitHub Desktop.
run commands interspersed with sleep
import sys
import argparse
import time
from subprocess import call
parser = argparse.ArgumentParser(description='Run a command for every line in a file, slowly.')
parser.add_argument('-s', type=float, help="Amount of seconds to sleep between commands", default=1.0)
parser.add_argument('file', type=file)
parser.add_argument('prefix', nargs=argparse.REMAINDER)
args = parser.parse_args()
for line in args.file:
time.sleep(args.s)
call(args.prefix + [line.strip()])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment