摘要: 1) 获取命令行参数,例如通过./abc.exp a1 a2执行expect脚本 set 变量名1 [lindex $argv 0] 获取第1个参数a1 set 变量名2 [lindex $argv 1] 获取第2个参数a2 2)函数中使用外部变量 例如在函数外部定义了变量va: set va "" 阅读全文
posted @ 2020-02-11 19:51 30岁再次出发 阅读(1639) 评论(0) 推荐(0) 编辑
摘要: 一.登陆到远程主机 脚本代码如下: ############################################## #!/usr/bin/expect set timeout 30 spawn ssh -l username hostip expect { "yes/no" { se 阅读全文
posted @ 2020-02-11 19:48 30岁再次出发 阅读(264) 评论(0) 推荐(0) 编辑
摘要: expect正则捕获返回结果expect: expect -re "([0-9]*)([a-zA-Z]*)"send_user "num is $expect_out(1,string), string is $expect_out(1,string)"这里[0-9]*表示一个或多个数字,[a-zA 阅读全文
posted @ 2020-02-11 19:47 30岁再次出发 阅读(1115) 评论(0) 推荐(0) 编辑