Re: How to automate user input at the command prompt?

2006-07-25 Thread gert365

Cameron Laird wrote:
 In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 
 In that case, the OP can probably use cygwin's version of python.
 pexpect definitely works there.
   .
   .
   .
 I suspect there are easier approaches--but probably won't have time
 before Monday to explain.  For now, I counsel the original poster
 not to be discouraged.

If you happen to have time to explain the possible approaches, it would
help me tremendously.  Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-22 Thread M�ta-MCI
Hi!


 There are typically only two output streams from a command line program. 
 stdout and stderr... Some of the OS triggered error messages
(abort, retry, fail) might be going to stderr -- so if you were looking at 
stdout, you won't see them.

- when you use  RD TOTO/S , win show the text Are-you sure (Y/N)? on 
stdout, and no stderr
- when the text is send, by win, on stdout, there are no RC ; consequently, 
subprocess (or popen) don't see anything
- it's possible, with popen4, with subprocess, to merge stdout  stderr in 
the same pipe


The problem remain entire.


@-salutations
-- 
Michel Claveau



-- 
http://mail.python.org/mailman/listinfo/python-list


How to automate user input at the command prompt?

2006-07-21 Thread gert365

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.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-21 Thread M�ta-MCI
Hi!

Same problem. I had search, long time, with popenX, with subprocess. I don't 
have, actually, any solution...

Suggestion: the first which finds prevents the others...

@+

Michel Claveau



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-21 Thread [EMAIL PROTECTED]

You may want to look at pexpect:

http://pexpect.sourceforge.net/

But I am not sure about its support on windows.

[EMAIL PROTECTED] 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.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-21 Thread Mike Kent

[EMAIL PROTECTED] wrote:
 You may want to look at pexpect:

 http://pexpect.sourceforge.net/

 But I am not sure about its support on windows.

To the best of my recent investigation, and an email exchange with the
author of pexpect, it is NOT supported under Windows.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-21 Thread [EMAIL PROTECTED]

In that case, the OP can probably use cygwin's version of python.
pexpect definitely works there.

Mike Kent wrote:
 [EMAIL PROTECTED] wrote:
  You may want to look at pexpect:
 
  http://pexpect.sourceforge.net/
 
  But I am not sure about its support on windows.

 To the best of my recent investigation, and an email exchange with the
 author of pexpect, it is NOT supported under Windows.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-21 Thread Cameron Laird
In article [EMAIL PROTECTED],
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

In that case, the OP can probably use cygwin's version of python.
pexpect definitely works there.
.
.
.
I suspect there are easier approaches--but probably won't have time
before Monday to explain.  For now, I counsel the original poster
not to be discouraged.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-21 Thread gert365

Cameron Laird wrote:
 In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 
 In that case, the OP can probably use cygwin's version of python.
 pexpect definitely works there.
   .
   .
   .
 I suspect there are easier approaches--but probably won't have time
 before Monday to explain.  For now, I counsel the original poster
 not to be discouraged.

Although I have not find the solution I need yet, thanks to the
suggestions so far I'm actually a bit more optimistic than before that
there might actually be a way to do what I want.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-21 Thread Gerhard Fiedler
On 2006-07-21 19:39:52, [EMAIL PROTECTED] wrote:

 Cameron Laird wrote:
 I suspect there are easier approaches--but probably won't have time
 before Monday to explain.  For now, I counsel the original poster
 not to be discouraged.
 
 Although I have not find the solution I need yet, thanks to the
 suggestions so far I'm actually a bit more optimistic than before that
 there might actually be a way to do what I want.

Until Cameron explains... maybe you can work out something with pipes (on
the program's stdin, stdout and stderr). Not sure how that would look like
in Python, though, and it almost for sure won't work with all command line
programs. (There are different ways how a program can read user input.)

Gerhard

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-21 Thread Roger Upole
If you have the Pywin32 extensions installed, you can use the
win32console module to send keystrokes directly to a command
prompt via WriteConsoleInput.

Roger

[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]

 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.
 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to automate user input at the command prompt?

2006-07-21 Thread M�ta-MCI
Hi!

I had try with pipes  subprocess. Unfortunaly, when dos-commandline show a 
text who question for Yes/No, this text is not available in subprocess/pipe 
;  = and block!
And then, I can't send Y to the stdin...

I test with:
 MD  TOTO
 RD  TOTO/S

(I know,  RD TOTO/S/Q run Ok, but I search another solution).

*sorry for my bad english*

Michel Claveau






-- 
http://mail.python.org/mailman/listinfo/python-list