Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43066
| Date | 2013-04-08 08:25 -0400 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: subprocess question re waiting |
| References | <ed0010ee-471d-4cbe-ae6c-1d9a172b2ffc@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.286.1365423942.3114.python-list@python.org> (permalink) |
On 04/08/2013 07:00 AM, loial wrote: > 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? > > Any help appreciated. > > > import subprocess > > command = "/home/john/myscript" > > process = subprocess.Popen(command, stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True, shell=True) > > out, err = process.communicate() > returncode = process.returncode > Yes, communicate() will block until the child process is complete. http://docs.python.org/2/library/subprocess.html#popen-objects Note the phrase: "Wait for process to terminate." That's referring to the shell in your case. -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
subprocess question re waiting loial <jldunn2000@gmail.com> - 2013-04-08 04:00 -0700
Re: subprocess question re waiting Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-04-08 13:48 +0200
Re: subprocess question re waiting Dylan Evans <dylan@dje.me> - 2013-04-08 22:01 +1000
Re: subprocess question re waiting Dave Angel <davea@davea.name> - 2013-04-08 08:22 -0400
Re: subprocess question re waiting Dylan Evans <dylan@dje.me> - 2013-04-08 22:58 +1000
Re: subprocess question re waiting Dave Angel <davea@davea.name> - 2013-04-08 08:25 -0400
csiph-web