> 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. -- http://mail.python.org/mailman/listinfo/python-list