小编Tim*_*Tim的帖子

将输入传递给 bash 中的交互式命令行程序

我有一个有自己提示的程序

example_program>
Run Code Online (Sandbox Code Playgroud)

我需要通过这个程序运行一系列命令

example_program> command_A
example_program> command B
Please enter input: [input_here]
example_program> command C
Run Code Online (Sandbox Code Playgroud)

我可以通过 shell 脚本中的以下行发送命令 A、B、C:

(echo "command_C" && cat) | (echo "command_B" && cat) | (echo "command_A" && cat ) | example_program
Run Code Online (Sandbox Code Playgroud)

如何输入所需的输入并在命令 B ([input_here]) 后提示输入?

我无权发送或期待。

linux bash shell echo cat

6
推荐指数
1
解决办法
5816
查看次数

标签 统计

bash ×1

cat ×1

echo ×1

linux ×1

shell ×1