On windows
I am trying to open a 'cmd' using subprocess in python. I plan to keep this cmd window open and send it commsnds to execute using the parent process.
args = "cmd.exe ".split()
creationflags_ = 0
creationflags_ |= subprocess.CREATE_NEW_CONSOLE
p = subprocess.Popen(args,creationflags = creationflags_,stdin=subprocess.PIPE) # Success!
while 1 :
str=sys.stdin.readline()
p.stdin.write(str)
Everything works fine till I give a garbage command - like jjjgfjg to the 'cmd'. As soon as the child executes it crashes. It seems that the child 'cmd' window is crashing when it writes to 'stderr'.
An ideas why this is happening?
Aucun commentaire:
Enregistrer un commentaire