Redirect stdin to bash?

As an example, I would like to enter mysql with a password. I KNOW I can use -pmypass, but I want to learn how to redirect stdin in bash. So my test

mysql -u limited_user -p <text to redirect into stdin when it prompts for my pass>

I saw <filename before, but I do not want to store data in a file. I tried both, and ... - but no luck. I'm not sure what ... - does.

+5
source share
2 answers

This is usually simple:

echo password|command

But many programs, including MySQL, which read passwords, are not actually read from stdin. Rather, they interact directly with the terminal. See Trick the app into thinking that its stdin is interactive, not a pipe .

+3
source
command <<< "input"

, bashism echo , ( , mysql, ).

+9

All Articles