start script automatically

Thomas Güttler guettler at thomas-guettler.de
Tue Jul 8 12:47:20 CEST 2003


Tom wrote:

> Hi,
> 
> I have a problem because I don't know how to start my script
> automatically after a special event happens.
> 
> In detail: I store data from a PLC. Every 30 seconds the data is stored
> in a new file. After the file is stored I would like to start my script
> that analyzes the data right away. Any help how to do this is deeply
> appreciated.

Hi,

I don't know what PLC is, but why not use an endless loop.
Files arrive in a directory called "input" and after processing
you move them to a directory called "done".

(not tested)
while 1:
    for file in os.listdir("input"):
        process(file)
        os.rename(os.path.join("input", file), os.path.join("done", file))
 
 thomas





More information about the Python-list mailing list