shell中嵌套执行expect命令实例
一直都想把expect的操作写到bash脚本里,这样就不用我再写两个脚本来执行了,搞了一下午终于有点小成就,给大家看看吧.
系统:centos 5.x
1.先安装expect
代码如下:
yum -y install expect
2.脚本内容:
代码如下:
cat auto_svn.sh #!/bin/bash passwd='123456' /usr/bin/expect <<-EOF set time 30 spawn ssh -p18330 [email protected] expect { "*yes/no" { send "yes\r"; exp_continue } "*password:" { send "$passwd\r" } } expect "*#" send "cd /home/trunk\r" expect "*#" send "svn up\r" expect "*#" send "exit\r" interact expect eof EOF
这样写的话,就方便得很多,一个脚本就包括完了.
相关推荐
libao 2020-09-16
xiaonamylove 2020-08-16
yoshubom 2020-07-18
Zaratustra 2020-07-18
赵家小少爷 2020-07-18
firefaith 2020-06-14
CARBON 2020-06-14
CARBON 2020-06-08
流年浅滩 2020-05-26
CARBON 2020-05-18
CARBON 2020-04-21
xiaobater 2020-04-29
gcong 2020-04-10
酷云的csdn 2020-03-25
onetozero 2020-03-08
SciRui 2020-02-21
higheels 2020-02-13