Bash 脚本调用需要交互式输入的 python 脚本(不仅仅是参数)

Bash 脚本调用需要交互式输入的 python 脚本(不仅仅是参数)

我有一个 bash 脚本bash.sh,如下所示:

#!/usr/bin/env bash
/usr/local/sbin/pythonScript.py firstArgument secondArgument

如果我使用两个命令行参数从终端调用 pythonScript.py,它会问我这个问题" Do you really want to accept this arguments ? ( yes / no )",我必须输入 yes 或 no,然后在终端中按 Enter 键才能恢复脚本执行。

现在我希望我的bash.sh脚本能够yes为我找到答案,但我不知道如何做。

我在我的脚本中尝试过类似的事情bash.sh

#!/usr/bin/env bash
echo "yes\n" | /usr/local/sbin/pythonScript.py firstArgument secondArgument

任何人都可以帮助我如何向 python 脚本提供动态命令行参数并模拟 ENTER 键按下。

编辑:

python 脚本正在读取On Unix, the prompt is written to the file-like object stream. stream defaults to the controlling terminal (/dev/tty)

相关内容