I have a program that interactively logins a user. I used the heredoc to automate the process.
./login <<EOF
[email protected]
password
EOF
I was expecting the output would be something like this. This is what it displays when I run the program without the heredoc and type in username and password myself.
$ ./login
Enter your email: [email protected]
Enter your password: password
Successfully logged in.
However, I only see this.
$ ./login
Enter your email:
Enter your password:
Successfully logged in.
As you can see, all of the heredoc inputs are not printed out, even though the program seems to be getting the stdin correctly. What's the reason for this? It would be great if I could still see those inputs to help me debug problems. Thanks.
CodePudding user response:
The login
program disables the local echo (see https://man7.org/linux/man-pages/man1/stty.1.html).
Update
If the login
program is writen by you, then is much easier, just echo
the values after reading them
CodePudding user response:
ECHO is a feature of the tty when users manually type chars to the tty. Your ./login << ...
does not get input from the tty so the heredoc is not echoed. It's just like, for example,
grep something < /some/file
where you don't want it to echo the whole file's data.