[Tutor] python's bash wait and ampersand equivalent?

chumpy town chumpytown at gmail.com
Tue Apr 26 19:49:43 CEST 2005


Thanks Pierre & Kent.  The subprocess.Popen worked beautifully.

-david

On 4/26/05, Kent Johnson <kent37 at tds.net> wrote:
> chumpy town wrote:
> > Hello all,
> > I am trying to convert from bash to python for scripting.  What is the
> > simplest & cleanest way to do the following in python:
> >
> > #!/bin/bash
> > for i in `seq 1 1000`
> >   do
> >   my-other-script &
> > done
> > wait
> > echo "all done"
> 
> You might like the subprocess module - something like this (untested!):
> 
> from subprocess import Popen
> procs = [ Popen("my-other-script") for i in range(1000) ]
> for p in procs:
>    p.wait()
> 
> Kent
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list