Expect : SSH login
作者:
喷射的熔浆 | 来源:发表于
2018-02-24 18:39 被阅读0次
Syntax
# assign variables
set variable_name variable_value
# do bash
spawn .....
# expect
expect ...
# send
send "..."
# interact
interact
Examples
#!/usr/bin/expect -f
set ipaddr "localhost"
set passwd "iforgot"
spawn ssh root@$ipaddr
expect {
"yes/no" { send "yes\r"; exp_continue}
"password:" { send "$passwd\r" }
}
expect "]# "
send "touch a.txt\r"
send "exit\r"
expect eof
exit
References
- how to use regex in switch case in expect script?
- Embedding an expect inside a bash script
- How do I embed an expect script that takes in arguments into a bash shell script?
- 6 Expect Script Command Line Argument Examples
本文标题:Expect : SSH login
本文链接:https://www.haomeiwen.com/subject/vukcxftx.html
网友评论