最近要在远程的一台服务器上比较频繁的进行svn更新,以便让测试部的同事进行测试,每次要ssh登录实在比较麻烦,查了下资料,然后写了一段expect自动脚本来完成这个任务:
#!/usr/bin/expect -f
set ipaddress 10.210.74.××
set passwd "sqwt××××"
set timeout 30
spawn ssh root@$ipaddress
expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "$passwd\r" }
}
expect "#"
send "cd /var/www/path1\n"
send "svn up\n"
send "cd /var/www/path2\n"
send "svn up\n"
send "exit\n"
expect eof