On Sun, 14 Nov 2010 19:47:55 +0000, Tim Harig wrote: > On 2010-11-14, Camille Harang <mammi...@garbure.org> wrote: >> # pg_dump prompts for password so I inject it in stdin. >> pgsql.stdin.write('MY_PASSWORD' + '\n') > > For security reasons, some programs use direct access to the TTY system > for password entry rather then reading from stdin.
Indeed, the getpass() function exists[1] for this purpose: The getpass() function opens /dev/tty (the controlling terminal of the process), outputs the string prompt, turns off echoing, reads one line (the "password"), restores the terminal state and closes /dev/tty again. [1] Or existed. It was dropped from the Unix standard in POSIX.1-2001, but most systems still provide it. -- http://mail.python.org/mailman/listinfo/python-list