#!/usr/bin/envpython#-*-coding:utf-8-*-importpexpectimportsysssh=pexpect.spawn(‘sshroot@192.168.20.103‘)fout=file(‘sshlog.txt‘,‘w‘)ssh.logfile=foutssh.expect("root@192.168.20.103‘spassword:")ssh.sendline("yzg1314520")ssh.expect(‘#‘)ssh.sendline(‘ls/home‘)ss..
分类:
编程语言 时间:
2015-09-10 17:32:16
阅读次数:
160
expect是建立在tcl基础上的一个工具,它用来让一些需要交互的任务自动化地完成。因为expect是基于tcl的,所以需要你的系统中安装有tcl如何检查?[root@dev ~]# whereis tcltcl: /usr/lib/tcl8.4 /usr/share/tcl8.4如果看不到结果,请先安装tcl安装> 安装tcl解压tcl安装包后cd tcl8.4.11/unix/./config...
分类:
系统相关 时间:
2015-09-08 20:15:25
阅读次数:
241
(1)首先,把要传输的主机ip保存到文件内viip10.161.4.x10.161.4.x10.161.4.x(2)编写脚本#!/usr/bin/kshusername=tomcat#这里是连接远程主机的用户名,本例中连接的远程主机用户名都一样#echo$usernamepassword=‘xxxxx‘#这里是密码#echo$passwordhomedir=">"ip_form=‘tomcat@..
分类:
系统相关 时间:
2015-09-07 14:27:30
阅读次数:
249
expect实现ssh自动登录#!/usr/local/bin/expectset PASSWD [lindex $argv 1]set IP [lindex $argv 0]set CMD [lindex $argv 2]spawn ssh $IP $CMDexpect "(yes/no)...
分类:
其他好文 时间:
2015-09-04 14:05:01
阅读次数:
151
expect 参数处理之一expect是很强悍的脚本,网上资源虽然很经典,但很少,我把自己的测试脚本贴之,仅作参考 #!/usr/bin/expect -f proc help {} { puts {usage: [-p ] [cmd] } } ...
分类:
其他好文 时间:
2015-09-04 14:01:49
阅读次数:
125
之前我在写shell脚本中嵌套expect遇到了这样的问题,最后经过研究发现,在expect中的shell命令是需要转换才能生效的。否知错误百出,让人吐血不已。下面我讲解下我所遇到的问题。我要实现通过ping检测存活主机。如果存活将这个IP存入root/uphost.txt这个文件中。并且用expect免..
分类:
系统相关 时间:
2015-09-02 19:13:29
阅读次数:
755
Expect是一个免费的编程工具语言,用来实现自动和交互式任务进行通信,而无需人的干预。 使用前需要先安装expect的rpm包,centos6.5 64位上的版本是expect-5.44.1.15-5.el6_4.x86_64 另外,可扩容是建立在/是逻辑...
分类:
其他好文 时间:
2015-09-01 15:23:49
阅读次数:
207
适配器模式 Adapter Pattern 变压器模式Convert the interface of a class into another interface clients expect.Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.将一个类的接口变换...
分类:
其他好文 时间:
2015-08-29 17:02:26
阅读次数:
169
小毛毛初拥expect前几天在写脚本的时候我有一个功能是想切换用户,让他自动输入密码。实现交互式的登陆。发现了expect这个工具。但是从来没有用过,所以也是出了很多问题。今天就来总结下!希望以后同样是新手的朋友不再走弯路。1.首先确认expect的包要安装成功我用的centos6...
分类:
其他好文 时间:
2015-08-28 02:27:09
阅读次数:
229