Welcome, guest | Sign In | My Account | Store | Cart

Execute a command-line argument repeatedly between arbitrary intervals of time.

Python, 21 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
import commands
import time
import os,sys,string
def main(comd,inc=60):
    while 1:
        os.system(comd)
        time.sleep(inc)



if __name__ == '__main__' :

    if len(sys.argv) <= 1:
        print "usage: " + sys.argv[0] + " command [increment]"
        sys.exit(1)
    comd = sys.argv[1]
    if len(sys.argv) < 3:
        main(comd)
    else:
        inc = string.atoi(sys.argv[2])
        main(comd,inc)

Combined with a script that changes background image, such as this one, you can have a fresh picture of usability guru Jakob Nielsen greeting you every [x] seconds. python pulse.py "perl setbg.pl" 180

setbg.pl requires lynx,wget,and xv

!/usr/local/bin/perl

if (@ARGV Combined with a script that changes background image, such as this one, you can have a fresh picture of usability guru Jakob Nielsen greeting you every [x] seconds. python pulse.py "perl setbg.pl" 180

setbg.pl requires lynx,wget,and xv

!/usr/local/bin/perl

if (@ARGV

1 comment

a 13 years, 12 months ago  # | flag

string.atoi() is deprecated. you should use int() instead