Hide keyboard input

Carsten Gaebler cg at schlund.de
Fri Nov 10 05:20:20 EST 2000


Hi!

I'm writing a program that is to be exectued via inetd and prompts for a
password. To read the password I'm using sys.stdin.readline() which has
the disadvantage that the password is printed on the screen while being
typed in. I tried getpass.getpass() to hide it but it raises an
exception (seems it's looking for some kind of terminal):

Password: Traceback (innermost last):
  File "/home/cg/src/python/ingoup/ingoup.py", line 20, in ?
    cleartext_passwd = string.strip(getpass.getpass())
  File "/usr/lib/python1.5/getpass.py", line 43, in getpass
    old = termios.tcgetattr(fd)	# a copy to save
termios.error: (22, 'Invalid argument')


Any solutions?

Regards
Carsten.



More information about the Python-list mailing list