
在Expect中为send语句添加变量的代码
5星
- 浏览量: 0
- 大小:None
- 文件类型:PDF
简介:
本文介绍了如何在Expect脚本中使用变量来增强send命令的功能,通过动态插入变量值实现更灵活的自动化交互。
代码如下:
```bash
#!usrbinexpect
set ssh_user fivetrees
set password 123456
spawn ssh -i root.ssh/$ssh_user root@xiaopp.3f.com
expect_before no)? {send yes\r }
sleep 1
expect Enter passphrase for key*
send $password\r
for {set snum 0} {$snum <= 6} {incr snum} {
expect *#
send ls -l optbackupfivetrees\r
}
```
注意:代码片段中存在一些语法错误和拼写问题,建议根据实际需求进行调试。
全部评论 (0)
还没有任何评论哟~


