By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

How to respond to a confirmation prompt automatically

P: n/a
Just to give you some background about my problem:

I execute os.system(command), where command is a string.

On the command line in windows, I get:

"Continue, and unload these objects? [no]"

I need to respond 'y' to continue, but I am uncertain on how to output
the 'y' automatically.
Thanks in advance.

Jan 12 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Coby" <fi********@gmail.comwrites:
Just to give you some background about my problem:

I execute os.system(command), where command is a string.

On the command line in windows, I get:

"Continue, and unload these objects? [no]"

I need to respond 'y' to continue, but I am uncertain on how to output
the 'y' automatically.
You need to use pipe.

1.

p = os.popen(command, "w")
p.write("y\n")

http://docs.python.org/lib/os-newstr...#os-newstreams

2.

from subprocess import Popen, PIPE
p = Popen(command, shell=True, stdin=PIPE)
p.stdin.write("y\n")

http://docs.python.org/lib/module-subprocess.html

--
HTH,
Rob
Jan 12 '07 #2

P: n/a
Thanks Rob.
Rob Wolfe wrote:
"Coby" <fi********@gmail.comwrites:
Just to give you some background about my problem:

I execute os.system(command), where command is a string.

On the command line in windows, I get:

"Continue, and unload these objects? [no]"

I need to respond 'y' to continue, but I am uncertain on how to output
the 'y' automatically.

You need to use pipe.

1.

p = os.popen(command, "w")
p.write("y\n")

http://docs.python.org/lib/os-newstr...#os-newstreams

2.

from subprocess import Popen, PIPE
p = Popen(command, shell=True, stdin=PIPE)
p.stdin.write("y\n")

http://docs.python.org/lib/module-subprocess.html

--
HTH,
Rob
Jan 12 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.