expect安装和测试
来源:互联网 发布:258优化网站 编辑:程序博客网 时间:2024/04/30 23:46
1.下载expect和tcl
下载地址:http://download.csdn.net/download/tobyaries/5754943
2.安装expect
tar -zxvf tcl8.4.11-src.tar.gz
tar -zxvf expect-5.43.0.tar.gz
cd tcl8.4.11/unix
./configure
make && make install
cd expect-5.43
./configure --with-tcl=/usr/local/lib/ --with-tclinclude=/data/software/tcl8.4.11
make && make install
3.脚本测试
#!/usr/bin/expect -fset timeout 30set name [lindex $argv 0]set pw [lindex $argv 1]log_user 0spawn passwd $namefor {set i 1} {$i < 3} {incr i} { expect "*password:" {send "$pw\r"}}expect "*successfully" send_user "Password updated successfully\n"expect eof
[解析]
很简单的程序,首先把第一个参数赋值给变量name作为用户名,把第二个参数赋值给pw作为密码。然后关闭标准输出,就是类似shell的 "> /dev/null",然后spawn开启子进程运行passwd程序,因为会重复输入2次密码,所以这里我们用到了TCL语法的for循环,执行2次密码输入。最后匹配到successfully字样的就输出修改成功,然后退出脚本。
0 0
- expect安装和测试
- 安装 Tcl 和 Expect
- expect安装测试-自动登陆脚本
- expect安装测试-批量用户管理
- 安装expect
- expect安装
- 安装expect
- expect 安装
- expect 安装
- expect安装
- expect安装
- 安装expect
- expect安装
- expect安装
- expect 安装
- Opensolaris: TCL和 Expect 编译与安装
- shell expect的简介和安装
- Linux下expect的安装和使用
- facebook分享(链接、照片、视频)
- HDU 1258 Sum It Up
- How To Set Up Apache Virtual Hosts on Ubuntu 14.04 LTS
- 二维码扫描之zxing与zbar的优劣
- Bzoj3782:上学路线:组合数学+Lucas+CRT+DP
- expect安装和测试
- 利用Java生成静态HMTL页面
- 使用ksoap2 jar包时 android meganto soap 请求错误报错NullPointerException
- VMware虚拟机共享主机无线网络联网的设置方法
- myeclipse,jdk,tomcat,MySQL配置
- 项目上传到cocoapods 打包framework上传到cocoapods
- AVC编码中的规格 :High、Baseline、Main什么意思?还有High@L3.0、High@L4.0、High@L5.1等
- fseek函数(转)
- Activity之间的动画切换学习笔记(一)