You probably want to try something like this:
command = "cmd.exe /C dir C:\"
I don't think you can pipe into cmd.exe
... If you are coming from a unix background, well, cmd.exe
has some ugly warts!
EDIT: According to Sven Marnach, you can pipe to cmd.exe
. I tried following in a python shell:
>>> import subprocess
>>> proc = subprocess.Popen('cmd.exe', stdin = subprocess.PIPE, stdout = subprocess.PIPE)
>>> stdout, stderr = proc.communicate('dir c:\')
>>> stdout
'Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporatio
n. All rights reserved.
C:\Python25>More? '
As you can see, you still have a bit of work to do (only the first line is returned), but you might be able to get this to work...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…