Remote control a script from home via dropbox
At my workplace I want to leave a script running on my desktop 24h/day. However, from home I cannot login to my machine, so if I want to stop/pause the script, I must go in to the office.
Still, how could I give commands for such a script from home?
I came up with the following idea. The script is put in my Dropbox folder and it is launched from there. At home I can create some special command files that are automatically synchronized on my office machine too. And when the script notices such a command file, it can react. My command files are called “stop” and “wait” and they can be empty.
The script checks periodically the presence of these files:
def check_commands(): """ Remote commands via dropbox. """ if os.path.isfile('stop'): os.unlink('stop') print '\nstop received, terminated.' sys.exit() # while os.path.isfile('wait'): sys.stdout.write('w') time.sleep(5)
The command “stop” terminates the script. The command “wait” pauses the program.