python input() not printing to screen when piping to another command

45 Views Asked by At

I have a simple python program that is using input to get a username and password, ie:


from getpass import getpass

username = input("Username: ")
password = getpass()

When i run the program and pipe to wc, the username prompt does not print. It takes input, and then the getpass prompt does print the passowrd prompt.

./example.py  | wc -l
sdfsdfsf # Not seeing the "Username: " prompt.
Password:
1

I've done some searches. I cannot find out why this is not printing. I am assuming it has to do with redirection or buffers, but I am not sure. Basically, trying to see if there is a way around this.

0

There are 0 best solutions below