Skip to content

Instantly share code, notes, and snippets.

@tangingw
Last active October 28, 2016 11:21
Show Gist options
  • Save tangingw/057c7ef45e9e5aefd3efe44d1d246dee to your computer and use it in GitHub Desktop.
Save tangingw/057c7ef45e9e5aefd3efe44d1d246dee to your computer and use it in GitHub Desktop.
This is a naughty script that mimics linux watch command on Mac OS X.
import os
import sys
import time
"""This is a naughty script
to mimic linux watch process
in Mac OS X terminal. It might be
useful for other *BSD family.
"""
def run_watch(unix_command, delay_time):
while True:
os.system("clear")
os.system(unix_command)
time.sleep(float(delay_time))
def main():
if len(sys.argv) != 3:
print "python watch.py <UNIX_CMD> <DELAY_TIME>"
else:
run_watch(sys.argv[1], sys.argv[2])
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print "Process ended!"
time.sleep(2)
os.system("clear")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment