我在bash shell中使用了expect。但是它们的语法似乎相互冲突。代码如下所示:
1 #! /bin/bash
2
3 SLJ_SERVERS=/data/qq_update/web/servers.conf
4
5 >wrong_server.log
6 while read line
7 do
8 if [[ "$line" == "s"* ]];then
9 export IP DIR
10 IP=`echo $line | awk -F: '{print $3}'`
11 DIR=`echo $line | awk -F: '{print $4}'`
12 echo "ip:$IP, dir:$DIR"
13
14 expect <<'END_OF_EXPECT'
exp_internal 1
15 spawn scp2 -o Port=36000 app27805@$env(IP):$env( DIR)/socket/conf/GameServerConfig.xml ./
16 set password "app27805"
17 expect {
18 "(yes/no)?" {
19 send "yes\r"
20 expect "password" {
21 send "$password\r"
22 }
23 }
24 "Password:" {
25 send "$password\r"
26 }
27 }
28 interact
29 END_OF_EXPECT
30 CONFIGURED_IP=`grep "ip" GameServerConfig.xml | awk -F\" '{print $4}'`
31 echo "configured ip:$CONFIGURED_IP" >> configured_ip.log
32 if [[ "$IP" != "$CONFIGURED_IP" ]];then
33 echo "server:$DIR, correct ip:$IP, wrong ip:$CON FIGURED_IP" >> wrong_server.log
34 fi
35 fi
36
37 done < $SLJ_SERVERS
现在我得到一个错误说:
我该如何解决这个问题。感谢您的帮助。