当前位置: 技术问答>linux和unix
linux大神帮帮忙?急!!!
来源: 互联网 发布时间:2017-05-21
本文导语: 我的shell脚本要连接远程ftp获取数据的,有这么一句:ftp -n ${LOG_FILE} #!/bin/sh LOG_FILE=/home/tiger/mytest/log/`basename $0`.`date +%Y%m%d%H%M%S`.log #check arguments if [ $# -ne 1 ]; then echo "error: arguments were n...
我的shell脚本要连接远程ftp获取数据的,有这么一句:ftp -n ${LOG_FILE}
#!/bin/sh
LOG_FILE=/home/tiger/mytest/log/`basename $0`.`date +%Y%m%d%H%M%S`.log
#check arguments
if [ $# -ne 1 ]; then
echo "error: arguments were not properly written!"|tee -a ${LOG_FILE};
echo "usage :`basename $0` "|tee -a ${LOG_FILE};
exit 1;
fi
BATCH_DATE=$1
FILE_NAMES="aa.txt bb.txt
cc.txt";
mkdir -p /home/tiger/mytest/data/$BATCH_DATE
ftp -n ${LOG_FILE}
open 172.28.0.36
user "test" "test"
binary
lcd /home/tiger/mytest/data/$BATCH_DATE
prompt
cd /home/test/mytest/$BATCH_DATE/
get 000.txt
close
bye
!
cd /home/tiger/mytest/data/$BATCH_DATE
if [ ! -f 000.txt ]; then
echo "000.txt not exists"|tee -a ${LOG_FILE};
exit -1;
else
ftp -n ${LOG_FILE}
open 172.28.0.36
user "test" "test"
binary
lcd /home/tiger/mytest/data/$BATCH_DATE
prompt
cd /home/test/mytest/$BATCH_DATE/
mget *.txt
close
bye
!
for FILENAME in $FILE_NAMES; do
if [ ! -f FILENAME ]; then
echo " $FILENAME not exists"|tee -a ${LOG_FILE};
exit -2;
fi
done
echo "pull $BATCH_DATE files successed!"|tee -a ${LOG_FILE};
exit 0;
fi
我运行脚本报错:receiptpulldata-test.sh: line 51: warning: here-document at line 30 delimited by end-of-file (wanted `!')
receiptpulldata-test.sh: line 52: syntax error: unexpected end of file
这里个"!"应该和什么地方的"!"产生了冲突,求指教?
#!/bin/sh
LOG_FILE=/home/tiger/mytest/log/`basename $0`.`date +%Y%m%d%H%M%S`.log
#check arguments
if [ $# -ne 1 ]; then
echo "error: arguments were not properly written!"|tee -a ${LOG_FILE};
echo "usage :`basename $0` "|tee -a ${LOG_FILE};
exit 1;
fi
BATCH_DATE=$1
FILE_NAMES="aa.txt bb.txt
cc.txt";
mkdir -p /home/tiger/mytest/data/$BATCH_DATE
ftp -n ${LOG_FILE}
open 172.28.0.36
user "test" "test"
binary
lcd /home/tiger/mytest/data/$BATCH_DATE
prompt
cd /home/test/mytest/$BATCH_DATE/
get 000.txt
close
bye
!
cd /home/tiger/mytest/data/$BATCH_DATE
if [ ! -f 000.txt ]; then
echo "000.txt not exists"|tee -a ${LOG_FILE};
exit -1;
else
ftp -n ${LOG_FILE}
open 172.28.0.36
user "test" "test"
binary
lcd /home/tiger/mytest/data/$BATCH_DATE
prompt
cd /home/test/mytest/$BATCH_DATE/
mget *.txt
close
bye
!
for FILENAME in $FILE_NAMES; do
if [ ! -f FILENAME ]; then
echo " $FILENAME not exists"|tee -a ${LOG_FILE};
exit -2;
fi
done
echo "pull $BATCH_DATE files successed!"|tee -a ${LOG_FILE};
exit 0;
fi
我运行脚本报错:receiptpulldata-test.sh: line 51: warning: here-document at line 30 delimited by end-of-file (wanted `!')
receiptpulldata-test.sh: line 52: syntax error: unexpected end of file
这里个"!"应该和什么地方的"!"产生了冲突,求指教?
|
xixi~~~
那有个办法 你将你的文件上传 我会下载下来一起分析的~
|
把作为end-of-file使用的“!”换成其他的表示呢?例如换成EOF
ftp -n ${LOG_FILE}
.....
.....
EOF
这样的
ftp -n ${LOG_FILE}
.....
.....
EOF
这样的