How to automate user input at the command prompt?

draghuram at gmail.com draghuram at gmail.com
Fri Jul 21 15:54:45 EDT 2006


You may want to look at pexpect:

http://pexpect.sourceforge.net/

But I am not sure about its support on windows.

gert365 at yahoo.com wrote:
> I'm working on a scirpt to be used on a windows machine and I need to
> automate a user's input on the command prompt.  For example I'm using
> os.system('mycommand') to excute the commands I want.  However some of
> these command will prompt for a confirmation of yes or no from user.
> Is there anything in python that will allow my script to automate these
> input
> Another example is let  say if i type "format c:\" on the command
> prompt it will warn me and ask me to type 'y' to continue.  I can use
> the os.system to automate the "format c:\" but is there a way to
> automate the 'y' input part.  I try searching for help on the Interent
> but cant seem find any info on how to do this with Python.  Can someone
> give me some confirmation if what I want to do is possible or not.
> Thanks in advance for any help.




More information about the Python-list mailing list