According to this StackOverflow thread about piping input, running echo "yes" | command
should pass yes
to the first prompt of a command. However, echo "yes" | python manage.py flush
produces the error
EOFError: EOF when reading a line.
I suspect that manage.py is requesting more than one line of input. Is there a reason you can't use
python manage.py flush --no-input
as documented?
Reading your comments, it appears you want to get the first one automated, and then have it ask for the rest.
You may or may not have learned this from that link:
The manage script asks for input on stdin. Echo passes its output to its stdout, then closes.
You want to pass the echoed 'yes' to stdout, followed by reading from keyboard.
cat <(echo "yes") - | python manage.py
Will concatenate (output from one, then the next) the content of echo yes
(pretending it's a file), followed by the content of stdin. As a result, you get the first automated answer, followed by a prompt for the rest.
Note that you can even do this more than once:
cat <(echo "yes") - <(echo "no") -
Will output "yes", followed by whatever you type in, until you end with ctl-d, followed by "no", followed by whatever you put in, until you end with ctl-d.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With