bash 如何将“是”传递给 python manage.py flush?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16345407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to pass 'yes' to python manage.py flush?
提问by Bentley4
According to this StackOverflow thread about piping input, running echo "yes" | commandshould pass yesto the first prompt of a command. However, echo "yes" | python manage.py flushproduces the error
根据这个关于管道输入的 StackOverflow 线程,运行echo "yes" | command应该传递yes到命令的第一个提示。但是,echo "yes" | python manage.py flush产生错误
EOFError: EOF when reading a line.
回答by msw
I suspect that manage.py is requesting more than one line of input. Is there a reason you can't use
我怀疑 manage.py 请求的输入不止一行。有什么不能使用的原因吗
python manage.py flush --no-input
as documented?
作为记录?
回答by zebediah49
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.
管理脚本要求在标准输入上输入。Echo 将其输出传递到其标准输出,然后关闭。
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.
将连接(从一个输出,然后是下一个)的内容echo yes(假装它是一个文件),然后是 stdin 的内容。因此,您会得到第一个自动回答,然后是其他提示。
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.
将输出“是”,然后是您输入的任何内容,直到以 ctl-d 结尾,然后是“否”,然后是您输入的任何内容,直到以 ctl-d 结尾。
回答by Julien Grenier
This will work, assuming that the yes command is installed (it should be) :
yes yes | python manage.py flush
这将起作用,假设安装了 yes 命令(应该是):
yes yes | python manage.py flush
But as mentionned :
python manage.py flush --no-inputis probably better.
但正如所提到的:
python manage.py flush --no-input可能更好。
回答by spbnick
Most likely "python manage.py flush" expects additional input after reading "yes", which it doesn't get, because "echo "yes"" finishes and its output file is closed.
很可能“python manage.py flush”在读取“yes”后需要额外的输入,但它没有得到,因为“echo“yes””完成并且其输出文件已关闭。
You need to figure out what else "python manage.py flush" expects and provide that on its input.
您需要弄清楚“python manage.py flush”还期望什么,并在其输入中提供。

