Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass 'yes' to python manage.py flush?

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.
like image 432
Bentley4 Avatar asked May 02 '13 18:05

Bentley4


2 Answers

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?

like image 155
msw Avatar answered Sep 17 '22 15:09

msw


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.

like image 23
zebediah49 Avatar answered Sep 20 '22 15:09

zebediah49