Redirect os.system output
Adriaan Renting
renting at astron.nl
Tue Oct 25 03:17:32 EDT 2005
Maybe Pexpect can help you, I think it does what you want, I'm just not sure it works on windows, as I think it uses pty's.
Please read it's FAQ about stdio buffer behaviour, I think it's also valid on Windows. pexpect.sourceforge.net
Adriaan Renting.
>>>"jas" <codecraig at gmail.com> 10/24/05 2:33 pm >>>
#I see that, although I don't totall grasp the code. However, I am
#looking to basically emulate a command prompt. i.e. everything u see
#in the windows command prompt should be displayed back in python.
#
#How can I do it without files?
#
#Kent Johnson wrote:
#>jas wrote:
#>>Any other ideas? or examples of using subprocess to do what I was
#>>asking?
#>
#>Actually I thought I was giving an example of what you were asking:
#>- on windows
#>- send a series of commands to a command process
#>- capture the result to a variable
#>
#>The example I referenced sends a series of HELP commands to cmd.exe, captures the output of the commands and saves it to a #file.
#>
#>What did I miss?
#>
#>Kent
#>
#>>
#>>
#>>Kent Johnson wrote:
#>>
#>>>jas wrote:
#>>>
#>>>>I would like to redirect the output from os.system to a variable, but
3>>>>am having trouble. I tried using os.popen(..).read() ...but that
#>>>>doesn't give me exactly what i want.
#>>>
#>>>Here is an example using subprocess:
#>>>http://groups.google.com/group/comp.lang.python/msg/9fa3a3c287e8e2a3?hl=en&
3>>>
#>>>Kent
#>>>
#>>>
More information about the Python-list
mailing list