1

嘿,我为我的 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
4

1 回答 1

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
于 2013-10-20T09:20:18.923 回答