shell脚本中的文件意外结束,无法找到错误

时间:2013-10-20 09:16:00

标签: linux shell upload raspberry-pi eof

嘿,我为我的pi编写了这个小的shell脚本来上传图片,但每次我运行脚本时我都会收到“意外的文件结束”,我甚至没有向我展示第一个回声。

感谢您的帮助:)

raspistill -o snapshot2.jpg
HOST=XXXXX  #This is the FTP servers host or IP address.
USER= XXXX            #This is the FTP user that has access to the server.
PASS=XXXXX        #This is the password for the FTP user.
NOW=$(date +"%c")

echo test

if [ -f work ];
then
    echo >> ftp.log "$NOW Script failure"
    echo ein prozess arbeitet noch

else
    echo beginne upload
    touch work
        ftp -inv $HOST << EOF
    user $USER $PASS
    cd /bilder2/
    put snapshot2.jpg   
    bye

    echo >> ftp.log "$NOW Upload Success"
    rm work
    echo erfolgreicher upload 
fi

EOF

1 个答案:

答案 0 :(得分:1)

fi应该放在 EOF之后,我猜你的脚本应该是这样的:

raspistill -o snapshot2.jpg
HOST=XXXXX  #This is the FTP servers host or IP address.
USER= XXXX            #This is the FTP user that has access to the server.
PASS=XXXXX        #This is the password for the FTP user.
NOW=$(date +"%c")

echo test

if [ -f work ];
then
    echo >> ftp.log "$NOW Script failure"
    echo ein prozess arbeitet noch

else
    echo beginne upload
    touch work
    ftp -inv $HOST << EOF
user $USER $PASS
cd /bilder2/
put snapshot2.jpg   
bye
EOF
    echo >> ftp.log "$NOW Upload Success"
    rm work
    echo erfolgreicher upload 
fi