- 论坛徽章:
- 0
|
本帖最后由 ywbj52 于 2014-03-25 16:09 编辑
主shell--update.sh- #!/bin/bash
- epg_list=`cat server_list`
- for addr in $epg_list
- do
- if [ "-$addr" = "-" ]
- then
- continue
- fi
- if [ `echo $addr | grep "#" | wc -l` -ge 1 ]
- then
- continue
- fi
- echo "begin dispatch to server["$addr"]"
- export addr
- #copy updatefile
- ./autocopy.sh
- if [ $? != 0 ];then
- echo "the ["$addr"] copyfile failed!"
- else
- echo "the ["$addr"] copyfile success!"
- fi
- done
复制代码 子shell--autocopy.sh- #!/usr/bin/expect
- #copy update file to server
- set password 123456
- spawn /usr/bin/scp /root/test.war root@$addr:/root
- set timeout 30
- expect {
- "yes/no" {send "yes\r";exp_continue}
- "password:" {send "$password\r"}
- }
- send "exit\r"
- expect eof
复制代码 执行./update.sh,一直提示can't read "addr": no such variable。网上有帖子说export一下变量,子shell就可以使用了,我试了不行,为啥呢。 |
|