On Thu, Jan 24, 2008 at 12:36:51PM -0500, Isaac Morland wrote: > What about an option (maybe even a default) to send the prompt to stdin? > > The Postgres command line interface psql appears to do this: > > $ psql 2>&1 >/dev/null > Password: > $ > > (I typed my password and then I quit by typing ^D; if I type the wrong > password, it looks the same on screen but it quits right away without > waiting for ^D) > > I think ssh also does this when it needs to prompt for a password.
One cannot write to stdin: >>> sys.stdin.write("1\n") Traceback (most recent call last): File "<stdin>", line 1, in <module> IOError: [Errno 9] Bad file descriptor But it is possible to explicitly open the current console for reading and writing and do I/O regardless of stdin/stdout/stderr redirects: >>> tty = open("/dev/tty", "r+") >>> tty.write("1\n") 1 >>> line = tty.readline() DDD >>> line 'DDD\n' Oleg. -- Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com