一个expect 的例子 (an expect example )

访问量: 1934

expect是一个非常好用, 但是可读性很差的东西。 所以我把一个简单的例子记录在这里: (expect is an automation tool, it's quite useful, at the same time, it grammer is quite un-readable. here is an example: )

#expect 自动输入密码的脚本: (服务器地址是: 10.103.13.73, 用户名 root, 密码 redAPPLE'

#!/usr/bin/expect
set timeout 100
system echo 'password: redAPPLE'
spawn ssh root@10.103.13.73 -p 22022
expect password
send "redAPPLE\r"
interact 

最后的那个interact 非常重要!  任何一个都不可或缺。   ( don't forget the last line! ) 

订阅/RSS Feed

Subscribe

分类/category