跳到主要内容

1 篇博文 含有标签「spawn」

查看所有标签

· 阅读需 1 分钟
大盗天放

expect spawn and send

#!/usr/bin/expect -f

#set timeout 20

set sp YourSudoPassword
set passwd UserPassword

# sudo is not always necessary

spawn sudo ssh user@ip

expect "Password:"
send "$sp\r"

expect "some stuff"
send "$passwd\r"
interact
  • spawn: run commands
  • expect: wait for specify pattern
  • send: to send the strings to the process