jay's blog
expect使用

expect 使用

deploy64() {
    /usr/bin/expect<<END
    set timeout 900
    spawn ssh [email protected]
    send "cd /home/admin/lp/upgrade\r"
    send "sh /home/admin/lp/upgrade/upgrade.sh\r"
    expect {
        "y/n" {send "y\r";exp_continue}
        "*Running*" {send "exit\r"}
    }
END
}
#!/usr/bin/expect
set timeout 10

spawn ssh [email protected] 
expect "*?Warning*"
send "cd /home/admin/lp/upgrade\r"
send "sh /home/admin/lp/upgrade/upgrade.sh\r"

expect "*?(y/n)*"
send "y\r"

expect "*安装结束*"
send "exit\r"

interact

reference

https://www.cnblogs.com/lzrabbit/p/4298794.html


最后修改于 2021-12-22