安装expect
来源:互联网 发布:淘宝阿沁家是正品吗 编辑:程序博客网 时间:2024/05/08 07:10
要使用expect需要预先安装tcl这个东西,然后再安装expect包.我这里使用的是tcl8.4.11-src.tar.gz和expect-5.43.0.tar.gz的安装包.
安装tcl和expect
#tar zxvf tcl8.4.11-src.tar.gz #cd tcl8.4.11/unix #./configure && make && make install #cp tclUnixPort.h ../generic/
#tar zxvf expect-5.43.0.tar.gz #cd expect-5.43/ #./configure --with-tcl=/usr/local/lib/ --with-tclinclude=\ /home/nagios/tcl8.4.11/generic/ --with-x=no
#make && make install
OK,tcl以及expect已经安装完成了.下面给出scp的一个expect很简单的一个脚本
#!/usr/local/bin/expect
spawn scp /home/nagios/tuning-primer.sh nagios@192.168.100.104:/home/nagios/
expect "Password:"
exec sleep 2
send "nagios&*(\n"
interact
ps: 如果提示缺tk,那么可能需要安装tk;
二、Windows下except的安装和使用
这是一个自动登录AIX服务器的例子。
1、先去如下地方下载expect:
windows">http://expect.nist.gov/#windows
ftp://bmrc.berkeley.edu/pub/winnt/tcltk/expect
2、安装默认路径是C:Program FilesExpect-5.21bin
expect.exe就在这里
3、写个简单的脚本sample.txt
spawn telnet aixserver
expect "login:"
send "mynamer"
expect "Password:"
send "mypassr"
send "lsr"
send "prtconfr"
expect eof
PS:网页的问题,脚本中的“\”等符号会丢失。
4、运行命令expect sample.txt看看效果
5、看看expect的一些帮助信息:
「开始」菜单程序Expect-5.21Tcl 8.0 Shell with Expect
敲?和help看看
ps:附相关文件下载地址
tcl: http://prdownloads.sourceforge.net/tcl/tcl8.4.16-src.tar.gz
tk: http://prdownloads.sourceforge.net/tcl/tk8.4.16-src.tar.gz
expect: http://sourceforge.net/projects/expect/files/Expect/5.45/expect5.45.tar.gz/download
- 安装expect
- expect安装
- 安装expect
- expect 安装
- expect 安装
- expect安装
- expect安装
- 安装expect
- expect安装
- expect安装
- expect 安装
- 安装 Tcl 和 Expect
- Fedora安装Expect
- linux下安装expect
- expect安装使用
- expect安装编译方法
- expect的安装使用
- expect 的安装
- 安装MySQL 4.12(完全安装,重新安装)
- Python_Python安装包下载
- MFC之VS2008的DEBUG和RELEASE
- DM642 FVID驱动
- 多线程编程1
- 安装expect
- ITIL学习(一) 概述
- C语言嵌入式系统编程之软件架构篇
- MyEclipse配置
- C++实现 反射 机制( 即根据 类名 创建 类实例)Create C++ Object Dynamically
- Centos 6.1源码安装mysql 5.5.21
- 多线程编程2
- CSS 杂记
- Tomcat内存溢出解决方法