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
相关推荐
linuxwcj 2020-10-21
bluecarrot 2020-08-19
luvzhan 2020-07-28
pimshell 2020-06-27
wiseMale 2020-06-01
SciRui 2020-05-06
BingGoGo技术 2020-03-03
gcong 2020-03-01
linuxhh 2020-02-15
86427019 2020-01-20
tvk 2020-01-09
quzhongwei 2020-01-06
风吹草动 2019-12-09
dmbjzhh 2019-11-08
onetozero 2019-11-08
supetan 2016-05-23
rickenwang 2019-11-03
beiya 2011-07-25