Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52287
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
| Newsgroups | comp.lang.python |
| Subject | Re: Simulate `bash` behaviour using Python and named pipes. |
| Date | Sat, 10 Aug 2013 13:07:03 +1200 |
| Lines | 22 |
| Message-ID | <b6li1pF6ksU1@mid.individual.net> (permalink) |
| References | <a4c08e1c-2915-48ed-a65d-2e1b89f28878@googlegroups.com> <mailman.209.1375711382.1251.python-list@python.org> <7f5c60c4-50c7-4a93-af22-5c8549f87461@googlegroups.com> <mailman.211.1375714293.1251.python-list@python.org> <fad1a298-993c-4935-9f32-7cf20ca63796@googlegroups.com> <mailman.214.1375718915.1251.python-list@python.org> <ec4048f5-fb66-4c4a-81c4-77435524e087@googlegroups.com> <mailman.216.1375731902.1251.python-list@python.org> <e31b1d44-e1b0-419e-a96c-6da8baaa755d@googlegroups.com> <mailman.221.1375742573.1251.python-list@python.org> <92074090-ae9e-4219-ae0f-21592e8f0133@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net vkxAS2rVKRC1zZlAbei9+A77UFEM2DpTVNEO7rzpMeppI7Fi7m |
| Cancel-Lock | sha1:Pcw9dEn1HDeTP6/uV8xWlr70yCE= |
| User-Agent | Mozilla Thunderbird 1.0.5 (Macintosh/20050711) |
| X-Accept-Language | en-us, en |
| In-Reply-To | <92074090-ae9e-4219-ae0f-21592e8f0133@googlegroups.com> |
| Xref | csiph.com comp.lang.python:52287 |
Show key headers only | View raw
Luca Cerone wrote:
> Thanks! I managed to make it work using the threading library :)
If at least one of the external programs can accept the source
or destination as a filename argument instead of redirecting its
stdin or stdout, you can also do something like this:
import subprocess
p2 = subprocess.Popen(["cat", "named_pipe"])
pipe = open("named_pipe", "w")
p1 = subprocess.Popen(["ls", "-lah"], stdout = pipe)
pipe.close()
p1.wait()
p2.wait()
That works because opening the reading end of the pipe is
done by the subprocess executing cat, leaving the main
process free to open the other end.
--
Greg
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Simulate `bash` behaviour using Python and named pipes. Luca Cerone <luca.cerone@gmail.com> - 2013-08-05 06:09 -0700
Re: Simulate `bash` behaviour using Python and named pipes. Paul Wiseman <poalman@gmail.com> - 2013-08-05 14:39 +0100
Re: Simulate `bash` behaviour using Python and named pipes. Luca Cerone <luca.cerone@gmail.com> - 2013-08-05 06:51 -0700
Re: Simulate `bash` behaviour using Python and named pipes. MRAB <python@mrabarnett.plus.com> - 2013-08-05 15:03 +0100
Re: Simulate `bash` behaviour using Python and named pipes. Luca Cerone <luca.cerone@gmail.com> - 2013-08-05 07:11 -0700
Re: Simulate `bash` behaviour using Python and named pipes. MRAB <python@mrabarnett.plus.com> - 2013-08-05 15:51 +0100
Re: Simulate `bash` behaviour using Python and named pipes. Luca Cerone <luca.cerone@gmail.com> - 2013-08-05 08:27 -0700
Re: Simulate `bash` behaviour using Python and named pipes. MRAB <python@mrabarnett.plus.com> - 2013-08-05 17:08 +0100
Re: Simulate `bash` behaviour using Python and named pipes. Luca Cerone <luca.cerone@gmail.com> - 2013-08-05 09:54 -0700
Re: Simulate `bash` behaviour using Python and named pipes. MRAB <python@mrabarnett.plus.com> - 2013-08-05 20:45 +0100
Re: Simulate `bash` behaviour using Python and named pipes. Luca Cerone <luca.cerone@gmail.com> - 2013-08-05 14:47 -0700
Re: Simulate `bash` behaviour using Python and named pipes. MRAB <python@mrabarnett.plus.com> - 2013-08-05 23:42 +0100
Re: Simulate `bash` behaviour using Python and named pipes. Luca Cerone <luca.cerone@gmail.com> - 2013-08-06 09:25 -0700
Re: Simulate `bash` behaviour using Python and named pipes. Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-08-10 13:07 +1200
Re: Simulate `bash` behaviour using Python and named pipes. Alister <alister.ware@ntlworld.com> - 2013-08-05 14:29 +0000
Re: Simulate `bash` behaviour using Python and named pipes. Luca Cerone <luca.cerone@gmail.com> - 2013-08-05 07:59 -0700
Re: Simulate `bash` behaviour using Python and named pipes. Neil Cerutti <neilc@norwich.edu> - 2013-08-05 16:00 +0000
csiph-web