<p>I've a python script that has to launch a shell command for every file in a dir:</p>

<pre><code>import os

files = os.listdir(".")
for f in files:
    os.execlp("myscript", "myscript", f)
</code></pre>

<p>This works fine for the first file, but after the "myscript" command has ended, the execution stops and does not come back to the python script.</p>

<p>How can I do? Do I have to <code>fork()</code> before <code>calling os.execlp()</code>?</p>

The
```
os.exec*()
```
functions
replace
the current programm with the new one. When this programm ends so does your process. You probably want
```
os.system()
```
.