Read/Write from/to a process
jas
codecraig at gmail.com
Tue Oct 25 08:22:20 EDT 2005
So it seems there is no good way to handle "interactive" processes on
windows using python. By interactive I mean processes/commands that
require user interaction, such as telnet or del (to delete a file or
directory sometimes you need to confirm with a yes or no), date, etc.
os.system gives the exact behavior, but you can't redirec the output.
pexpect isn't supported on windows. Even with subprocess you can't
handle all/most cases..since you have to do things like look for he
prompt.
I modified the original suggestion so it would update the prompt, in
case the user did a "cd.." ..which works fine now. However, if a user
tries to do, "del tmp123" ...windows prompts for a "are you sure you
want to delete... Y/N?" ...so the code hangs.
I can't believe no one else has done this yet..or if they have, it
hasn't been widely discussed.
Any other suggestions?
More information about the Python-list
mailing list