Read/Write from/to a process

Steve Holden steve at holdenweb.com
Tue Oct 25 08:31:22 EDT 2005


jas wrote:
> 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?
> 
Look at how you might do it in other languages. Then you'll realise this 
isn't (just) a Python problem.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list