[英]Pass input to interactive command line program in bash
我有一個有自己提示的程序
example_program>
我需要通過這個程序運行一系列命令
example_program> command_A
example_program> command B
Please enter input: [input_here]
example_program> command C
我可以通過shell腳本中的以下行發送命令A,B,C:
(echo "command_C" && cat) | (echo "command_B" && cat) | (echo "command_A" && cat ) | example_program
如何輸入所需的輸入並在命令B([input_here])后提示輸入?
我沒有發送或期望的權限。
我猜這會有效,但這只是猜測,因為我們不知道你的程序如何讀取響應:使用here-doc,並在調用命令B后輸入命令B
example_program <<'END'
command_A
command B
input_here
command C
END
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.