Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53573
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <random832@fastmail.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'sys': 0.07; 'subject:help': 0.08; 'ping': 0.09; 'received:internal': 0.09; 'python': 0.11; 'creates': 0.14; 'cmd': 0.16; 'invoking': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'stderr': 0.16; 'stdout': 0.16; 'subject:txt': 0.16; 'to:name:venkatesh': 0.16; 'venkatesh': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; 'code,': 0.22; 'import': 0.22; 'this?': 0.23; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'invoke': 0.31; 'sep': 0.31; 'skip:c 30': 0.32; 'subject:the': 0.34; 'received:66': 0.35; 'achieving': 0.36; 'should': 0.36; 'received:10': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'unable': 0.39; 'from:no real name:2**0': 0.61; "you're": 0.61; 'header:Message-Id:1': 0.63; 'group,': 0.63; 'to:addr:gmail.com': 0.65; 'subject:. ': 0.67; '2013,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:subject:date:in-reply-to:references; s=mesmtp; bh= chi2KTNr92Zu9FrRxAZC9Ej+0/A=; b=YY5zBbl/5eZ4/SZJOd8F+cB14UEVLM9d y1G9QBEa981xAzDqEg/BNsi4yiUjaJDeLHkuYTY1NsUFsysBh0PimCetczKVxrBc 7BqV16bSznC1fQaudCC6y3+08EK3Bs5FE6ZYdWSHHF0i3uuQe9O7I94aNKr/ecIF OUR+jW4O2Jg= |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:subject:date:in-reply-to :references; s=smtpout; bh=chi2KTNr92Zu9FrRxAZC9Ej+0/A=; b=HnJW2 TgGgDW34QZ1Spp0M9W6tB9EDyzlQGOW6cKhJyFLS6UORlJn9RREnyhr6Bx80Mpch TQru8j+j0xrID3wYpA2D/PWF7yo9uM44nSFkWIXo6n4u9ZwHqbXSdW2rs7IZw4Do lSVBNiYDLV37FMsYVRGIJoWpEqKcHoPztA5Cfk= |
| X-Sasl-Enc | DzBBr0/xhVz2oEtY+/HL986jeV2X5WK8EGTuiE3tSVK+ 1378225302 |
| From | random832@fastmail.us |
| To | Venkatesh <venkatesh.totad@gmail.com>, python-list@python.org |
| MIME-Version | 1.0 |
| Content-Transfer-Encoding | 7bit |
| Content-Type | text/plain |
| X-Mailer | MessagingEngine.com Webmail Interface - ajax-ed2f0e98 |
| Subject | Re: Unable to redirect the subprocess CMD.exe to txt file. Please help !!! |
| Date | Tue, 03 Sep 2013 12:21:42 -0400 |
| In-Reply-To | <3c50a8aa-261f-447d-b07c-cdad3a5465e0@googlegroups.com> |
| References | <3c50a8aa-261f-447d-b07c-cdad3a5465e0@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8.1378225305.5461.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1378225305 news.xs4all.nl 15972 [2001:888:2000:d::a6]:34688 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:53573 |
Show key headers only | View raw
On Tue, Sep 3, 2013, at 9:54, Venkatesh wrote:
> Hello comp.lang.python Group,
>
> I am trying to invoke a subprocess in Python as below
>
> import sys
> import time
> import os
> import subprocess
> DETACHED_PROCESS = 0x00000008
>
> path = r'C:\Windows\System32\cmd.exe /k ping www.google.com -n 4 >>
> temp.txt'
> p = subprocess.Popen("%s"%(path), stdout = subprocess.PIPE, stderr =
> subprocess.STDOUT, creationflags=DETACHED_PROCESS)
>
> With this code, unable to invoke the subprocess and hence not able to
> store the Ping statistics in the file.
>
> Any help on this OR any better way of achieving this??
You should use /c, instead of /k. /k creates an interactive prompt.
I think you're being a bit overly complicated though by invoking cmd at
all. What about this?
subprocess.Popen("ping www.google.com -n 4",
stdout=open('temp.txt','a'), ...)
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Unable to redirect the subprocess CMD.exe to txt file. Please help !!! Venkatesh <venkatesh.totad@gmail.com> - 2013-09-03 06:54 -0700 Re: Unable to redirect the subprocess CMD.exe to txt file. Please help !!! William Ray Wing <wrw@mac.com> - 2013-09-03 10:22 -0400 Re: Unable to redirect the subprocess CMD.exe to txt file. Please help !!! random832@fastmail.us - 2013-09-03 12:21 -0400
csiph-web