Created
January 11, 2017 01:44
-
-
Save chadselph/b62c421a1f974b255dfd384e09f1f330 to your computer and use it in GitHub Desktop.
run commands interspersed with sleep
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 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