2013-10-20 51 views
1

嘿,我写了这个小的shell脚本为我的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

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