Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25159

RE: how to interact with Windows cmd?

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 <ramit.prasad@jpmorgan.com>
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" <ramit.prasad@jpmorgan.com>
To "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2002.1341959383.4697.python-list@python.org> (permalink)
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

Show key headers only | View raw


> what I want to do is
> 1.open cmd
> 2.waiting for user's typing
> 3.when I type "dir"
> 4.print the result of "dir"
> 5.then I type some other commands, printing the result until I type
> 'exit'
> 
> I used
> p=subprocess.Popen('cmd',stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=s
> ubprocess.PIPE,shell=True)
> p=communicate('dir')
> 
> it shows the first result but the problem is
> 1. it's too long so the cmd split the result with "more?", so result
> is not perfect
> 2. after this, I typed like "cd .." but I/O is already closed so I
> can't do another things..
> 
> Is there any good way?

Not much experience with subprocess, but from what I have read
on here shell=True is usually bad. If you are trying to use 
Python as a sort of bash replacement, you may want to take a 
look at iPython http://en.wikipedia.org/wiki/Ipython. 

Not Apple related!

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

how to interact with Windows cmd? "self.python" <howmuchistoday@gmail.com> - 2012-07-04 20:10 -0700
  Re: how to interact with Windows cmd? Nobody <nobody@nowhere.com> - 2012-07-05 17:11 +0100
  RE: how to interact with Windows cmd? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-07-10 22:29 +0000

csiph-web