Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108150
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Akira Li <4kir4.1i@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Interacting with Subprocesses |
| Date | Thu, 05 May 2016 00:04:02 +0300 |
| Lines | 36 |
| Message-ID | <mailman.391.1462395856.32212.python-list@python.org> (permalink) |
| References | <MPG.3193e21979405e40989683@news.supernews.com> <871t5h4jst.fsf@gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| X-Trace | news.uni-berlin.de Rc4fk+cEZKtT+x+yZkSmJQ9jFTSNU6VM6DHnSPwQJYIw== |
| Cancel-Lock | sha1:65IMuw3NAW8sNYOP4y14ak+qUa0= |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.019 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'input,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'output': 0.13; 'buffering': 0.16; 'pair,': 0.16; 'pairs': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subprocess': 0.16; 'url:faq': 0.16; 'pass': 0.22; 'seems': 0.23; 'tried': 0.24; 'feature': 0.24; 'module': 0.25; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'question': 0.27; 'attempting': 0.29; 'btw,': 0.29; 'dialog': 0.29; 'initiate': 0.29; 'environment': 0.29; 'objects': 0.29; "i'm": 0.30; 'code': 0.30; "can't": 0.32; 'related': 0.32; 'continuing': 0.32; 'returned': 0.32; 'run': 0.33; 'useful': 0.33; 'problem': 0.33; 'source': 0.33; 'message-id:@gmail.com': 0.34; 'file': 0.34; 'list': 0.34; 'could': 0.35; 'execution': 0.35; 'interact': 0.35; 'protocol': 0.35; 'but': 0.36; 'there': 0.36; 'child': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'url:en': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'some': 0.40; 'behavior': 0.61; 'skip:u 10': 0.61; 'programs': 0.62; 'between': 0.65; 'url:info': 0.71; 'received:89': 0.80; 'communicate,': 0.84; 'streams': 0.84; 'url:readthedocs': 0.84; 'medium.': 0.91; 'responses': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | 89.169.229.68 |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <871t5h4jst.fsf@gmail.com> |
| X-Mailman-Original-References | <MPG.3193e21979405e40989683@news.supernews.com> |
| Xref | csiph.com comp.lang.python:108150 |
Show key headers only | View raw
Dick Holmes <encore1@cox.net> writes: > I am attempting to write a Python program that will interact with > a (non-Python) process. The programs will run under MinGW. The > process can use stdin/stdout commands and responses and can work > with pipes. The problem I'm having is that I can't find any > way in Python to have a continuing dialog with the process. I > have tried Popen communicate, but that protocol seems to be > limited to a single message/response pair, and the response > is not returned to the message originator until the process > terminates. Unfortunately I don't have access to the process' > source code so I can't change the communication medium. > > Is there some feature that will allow me to initiate the process > and execute multiple message/response pairs between the Python > program and the process during a single execution of the process? > Pass stdin=PIPE, stdout=PIPE and use p.stdin, p.stdout file objects to write input, read output from the child process. Beware, there could be buffering issues or the child process may change its behavior some other way when the standard input/output streams are redirected. See http://pexpect.readthedocs.io/en/stable/FAQ.html#whynotpipe btw, If pexpect module works in MingGW environment (if pty is available); you could try it to communicate with the process interactively. You might also find the list of Stackoverflow question related to the subprocess module useful http://stackoverflow.com/tags/subprocess/info Akira
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Interacting with Subprocesses Dick Holmes <encore1@cox.net> - 2016-05-04 11:41 -0700 Re: Interacting with Subprocesses Akira Li <4kir4.1i@gmail.com> - 2016-05-05 00:04 +0300 Re: Interacting with Subprocesses Terry Reedy <tjreedy@udel.edu> - 2016-05-04 20:33 -0400 Re: Interacting with Subprocesses Akira Li <4kir4.1i@gmail.com> - 2016-05-05 04:05 +0300 Re: Interacting with Subprocesses eryk sun <eryksun@gmail.com> - 2016-05-05 04:38 -0500
csiph-web