bg and fg
Stefan Antoni
sasoft at gmx.de
Sun Nov 4 11:25:51 EST 2001
- i am using linux
- i got a script that takes the time.ctime string and
compares it with a set time. if the time is the same
as the set time, it will do something.
- the script is a non-gui application (see bottom of this mail)
question:
1. how can i move my process in the background after i
started it (like: myscript & -> but automatically).
2. how do i move it back in the foreground when the
action for the set time is performed?
... i had a look at the "os" module, but i dunno what i
should use (do i have to fork my script in the bg or something?)
#!/usr/bin/env python
import time, sys, os
def main(hour, minute):
print "clock set to %s" % (hour + ":" + minute)
time.sleep(1)
while 1:
try:
currentTime = time.ctime(time.time())
if (currentTime[11] + currentTime[12]) == hour and \
currentTime[14] + currentTime[15] == minute:
print "\a"
time.sleep(0.5)
else:
pass
except KeyboardInterrupt:
print "ctrl+c pressed, exiting"
sys.exit(1)
if __name__ == '__main__':
try:
main(str(sys.argv[1]), str(sys.argv[2]))
except IndexError:
print "format is: wecker hour minute"
--
thx in advance
Stefan Antoni
More information about the Python-list
mailing list