How to input automatically when running a shell over SSH?

前端 未结 5 1735
囚心锁ツ
囚心锁ツ 2020-12-02 09:30

In my shell script I am running a command which is asking me for input.

How can I give the command the input it needs automatically?

For example:

<         


        
5条回答
  •  臣服心动
    2020-12-02 10:13

    There definitely is... Use the spawn, expect, and send commands:

    spawn test.sh
    expect "Are you sure you want to continue connecting (yes/no)?"
    send "yes"
    

    There are more examples all over Stack Overflow, see: Help with Expect within a bash script

    You may need to install these commands first, depending on your system.

提交回复
热议问题