Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '"the': 0.07; 'alain': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'command,': 0.16; 'finish.': 0.16; 'it."': 0.16; 'it."': 0.16; 'wrote:': 0.18; 'users.': 0.18; 'email addr:gmail.com>': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'script': 0.25; '>': 0.26; 'header:In-Reply- To:1': 0.27; 'unix': 0.29; 'andrew': 0.30; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'writes:': 0.31; 'run': 0.32; 'url:python': 0.33; '"the': 0.34; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'pm,': 0.38; 'does': 0.39; 'url:mail': 0.40; 'how': 0.40; 'nobody': 0.68; 'received:mail-ob0-x22d.google.com': 0.84; 'to:none': 0.92; '2013': 0.98 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:in-reply-to:references :date:message-id:subject:from:cc:content-type:x-gm-message-state; bh=9y19hGS+cli6qDS6cuhsnt0Lou9qe2CQZlRbnaqh5f8=; b=gOiAYCu4XUohaDfdMnA69jqRSoRglOAo+//D4ADGEjDLhO6o+WMhdiXLhJMxUwGD4l lDLZp7R2NRoYJPPPi2gd60trTKuy8keWUDZu+yUi372pOWLtw3zw3hyEdlDj1f0znlmC VyGmxMYnC5mmnY3GjRFeboh58U8rh5KH0xRXMepXPvGXZl0qTJTFTp6ZO0Nk8DjnVLiK DJRlHWZKPbBl+2FzW665OodgKHBzBPajlnyG80cCJyTjfaFZmiyiUZ4hmwvG8sgdmSQq GlvoBUXBc6L0KNoklUbFz7REORnbWYNEKUKWjxWst0ovYQYAAlT/OUbnN3NtyMXhGUev bgrw== MIME-Version: 1.0 X-Received: by 10.182.134.230 with SMTP id pn6mr15062341obb.19.1365422512620; Mon, 08 Apr 2013 05:01:52 -0700 (PDT) X-Originating-IP: [220.245.216.139] In-Reply-To: <8761zxdyzb.fsf@dpt-info.u-strasbg.fr> References: <8761zxdyzb.fsf@dpt-info.u-strasbg.fr> Date: Mon, 8 Apr 2013 22:01:52 +1000 Subject: Re: subprocess question re waiting From: Dylan Evans Cc: python-list Content-Type: multipart/alternative; boundary=001a11c2bf80d558f404d9d83300 X-Gm-Message-State: ALoCoQlkISvzKYlZVCejyAQ69AFchwMMolQpNmD3jw5kIORWAf6z2W2wZQ5OW7R9va9n6i/PspvR X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365422522 news.xs4all.nl 6900 [2001:888:2000:d::a6]:36133 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43064 --001a11c2bf80d558f404d9d83300 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Apr 8, 2013 at 9:48 PM, Alain Ketterlin wrote: > loial writes: > > > I want to call a child process to run a shell script and wait for that > > script to finish. Will the code below wait for the script to finish? > > If not then how do I make it wait? > [...] > > process = subprocess.Popen(command, > stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE, > close_fds=True, shell=True) > > process.wait() > Or use subprocess.call instead which does what you want. > -- Alain. > -- > http://mail.python.org/mailman/listinfo/python-list > -- "The UNIX system has a command, nice ... in order to be nice to the other users. Nobody ever uses it." - Andrew S. Tanenbaum --001a11c2bf80d558f404d9d83300 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Mon, Apr 8, 2013 at 9:48 PM, Alain Ketterlin &= lt;alain@d= pt-info.u-strasbg.fr> wrote:
loial <jldunn2000@gmail.com> writes:

> I want to call a child process to run a shell script and wait for that=
> script to finish. Will the code below wait for the script to finish? > If not then how do I make it wait?
[...]
> process =3D subprocess.Popen(command, stdin=3Dsubprocess.PIPE,std= out=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, close_fds=3DTrue, shell=3D= True)

process.wait()

Or use subprocess.= call instead which does what you want.=A0


-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list



--
"The UNIX system has a command, nice ... in order to be nice to= the other users. Nobody ever uses it." - Andrew S. Tanenbaum
--001a11c2bf80d558f404d9d83300--