Created
February 22, 2016 10:13
-
-
Save InFog/bf2d7058631f0aaa9883 to your computer and use it in GitHub Desktop.
Revisions
-
InFog created this gist
Feb 22, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ #!/usr/bin/env python2 # # This script will run something every 2 seconds and print a line in between # # Usage: intrun command from subprocess import call from sys import argv, exit from time import sleep def show_help(): print "Command to run is missing!\n\tUsage %s command\n" % argv[0] def validate_input(): if len(argv) != 2: return False return True def get_command(): return argv[1] def print_line(): print "\n" print "-" * 120 print "\n" def main(): if not validate_input(): show_help() return 1 command = get_command() while True: try: call(command) print_line() sleep(2) except KeyboardInterrupt: return 0 except OSError: print "Command '%s' not found\n" % command return 2 if __name__ == "__main__": exit(main())