expect中为send语句上加变量的代码_linuxshell教程-查字典教程网
expect中为send语句上加变量的代码
expect中为send语句上加变量的代码
发布时间:2016-12-28 来源:查字典编辑
摘要:复制代码代码如下:#!/usr/bin/expectsetssh_user"fivetrees"setpassword"123456"spa...

复制代码 代码如下:

#!/usr/bin/expect

set ssh_user "fivetrees"

set password "123456"

spawn ssh -i /root/.ssh/$ssh_user root@xiaopp.3f.com

expect_before "no)?" {

send "yesr" }

sleep 1

expect "Enter passphrase for key*"

send "$passwordr"

for {set snum 0} {$snum <= 6} {incr snum} {

expect "*#"

send "ls -l /opt/backup/fivetreesdb_s$snumr"

sleep 3

}

sleep 2

expect "*#"

send "echor"

exit

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新linuxshell学习
    热门linuxshell学习
    脚本专栏子分类