Path: csiph.com!usenet.pasdenom.info!news.albasani.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'bash': 0.07; 'completeness': 0.07; 'subject:Windows': 0.09; 'python': 0.09; 'cmd': 0.09; 'received:155': 0.09; 'typed': 0.09; '.."': 0.16; 'currencies': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:159.53': 0.16; 'received:169.70': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'skip:p 70': 0.16; 'subprocess,': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'typing': 0.17; 'to:name:python-list@python.org': 0.20; 'sort': 0.21; 'trying': 0.21; 'commands,': 0.22; "user's": 0.22; 'split': 0.23; 'received:169.254': 0.24; 'header:In-Reply-To:1': 0.25; 'url:wiki': 0.26; 'accuracy': 0.27; 'bad.': 0.29; 'chase': 0.29; 'i/o': 0.29; 'url:wikipedia': 0.29; 'way?': 0.29; 'received:169': 0.29; 'usually': 0.30; 'header:Received:8': 0.30; 'problem': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; "can't": 0.34; 'phone:': 0.34; 'subject:?': 0.35; 'there': 0.35; 'skip:u 20': 0.36; 'but': 0.36; 'url:org': 0.36; 'apple': 0.36; 'subject:with': 0.36; 'too': 0.36; 'charset:us-ascii': 0.36; 'skip:p 20': 0.36; 'subject:: ': 0.38; 'some': 0.38; 'shows': 0.38; 'url:en': 0.38; 'to:addr:python.org': 0.39; 'first': 0.61; 'perfect': 0.63; 'information,': 0.63; 'url:email': 0.63; 'here': 0.65; 'legal': 0.65; 'subject': 0.66; 'investment': 0.67; 'purchase': 0.67; 'sale': 0.76; 'bank': 0.77; '712': 0.84; 'received:169.254.8': 0.84; 'houston,': 0.91 X-DKIM: OpenDKIM Filter v2.1.3 sz2.jpmchase.com q6AMTalp031093 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1341959376; bh=H4kWbZEZTSsLWAoI4hVk6NnU1kEY3dUkNv97ZVF/LF4=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=DFV0HaAQk1nv6yszvu/8RlmJh4hpO9NToReab5Mi6lMownvePnfww/DATcgz6ncZ0 r9LZ6nR6KfgoCNhe/+BKgKReNHOURAuc6ZPghokVLXbYcSItzuFvWzRUP7857Jt++f Z3do5+E2jK485eQD2PfPBFo5NuqwOvnKE6F+hxlg= From: "Prasad, Ramit" To: "python-list@python.org" Subject: RE: how to interact with Windows cmd? Thread-Topic: how to interact with Windows cmd? Thread-Index: AQHNWlxlVXKHd4fSJE2Cp+X1uF0uBJcjIUUQ Date: Tue, 10 Jul 2012 22:29:29 +0000 References: <5c91bf76-36de-4759-938a-92a9e801e38e@g4g2000pbn.googlegroups.com> In-Reply-To: <5c91bf76-36de-4759-938a-92a9e801e38e@g4g2000pbn.googlegroups.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes Content-Type: text/plain; charset="us-ascii" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341959383 news.xs4all.nl 6862 [2001:888:2000:d::a6]:39525 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25159 > what I want to do is=0D=0A> 1=2Eopen cmd=0D=0A> 2=2Ewaiting for user's ty= ping=0D=0A> 3=2Ewhen I type "dir"=0D=0A> 4=2Eprint the result of "dir"=0D= =0A> 5=2Ethen I type some other commands, printing the result until I type= =0D=0A> 'exit'=0D=0A> =0D=0A> I used=0D=0A> p=3Dsubprocess=2EPopen('cmd',st= din=3Dsubprocess=2EPIPE,stdout=3Dsubprocess=2EPIPE,stderr=3Ds=0D=0A> ubproc= ess=2EPIPE,shell=3DTrue)=0D=0A> p=3Dcommunicate('dir')=0D=0A> =0D=0A> it sh= ows the first result but the problem is=0D=0A> 1=2E it's too long so the cm= d split the result with "more?", so result=0D=0A> is not perfect=0D=0A> 2= =2E after this, I typed like "cd =2E=2E" but I/O is already closed so I=0D= =0A> can't do another things=2E=2E=0D=0A> =0D=0A> Is there any good way?=0D= =0A=0D=0ANot much experience with subprocess, but from what I have read=0D= =0Aon here shell=3DTrue is usually bad=2E If you are trying to use =0D=0APy= thon as a sort of bash replacement, you may want to take a =0D=0Alook at iP= ython http://en=2Ewikipedia=2Eorg/wiki/Ipython=2E =0D=0A=0D=0ANot Apple rel= ated!=0D=0A=0D=0ARamit=0D=0A=0D=0A=0D=0ARamit Prasad | JPMorgan Chase Inves= tment Bank | Currencies Technology=0D=0A712 Main Street | Houston, TX 77002= =0D=0Awork phone: 713 - 216 - 5423=0D=0A=0D=0A--=0D=0A=0D=0AThis email is c= onfidential and subject to important disclaimers and=0D=0Aconditions includ= ing on offers for the purchase or sale of=0D=0Asecurities, accuracy and com= pleteness of information, viruses,=0D=0Aconfidentiality, legal privilege, a= nd legal entity disclaimers,=0D=0Aavailable at http://www=2Ejpmorgan=2Ecom/= pages/disclosures/email=2E