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


Groups > comp.lang.python > #25159

RE: how to interact with Windows cmd?

From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Subject RE: how to interact with Windows cmd?
Date 2012-07-10 22:29 +0000
References <5c91bf76-36de-4759-938a-92a9e801e38e@g4g2000pbn.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2002.1341959383.4697.python-list@python.org> (permalink)

Show all headers | 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