Aim: When motion is triggered save a snapshot every xx seconds for xx times. After that upload the pictures to a FTP server.
I copied and modified this script together:
Code: Select all
#!/bin/sh
today=`/bin/date '+%d-%m-%Y__%H-%M'`; #Used to generate file-/foldername
IP="192.168.1.102" # IP address Camera
#Ping IP-address of camera to see if it's online, otherwise we don't have to $
if ping -c 1 $IP > /dev/null ; then #Grab snapshot
#Create folder named with timestamp
mkdir /home/fa/domoticz/smbfiles/ipcam/$today
#Get Snapshot from camera. Every 10 seconds for 10 times and save in new folder
for d in $(seq 1 10); do wget "http://192.168.1.102:8081/photoaf.jpg" -O /home/fa/domoticz/smbfiles/ipcam/$today/$(date +%d-%m-%Y__%H-%M-%S).jpeg; sleep 10; done;
#Send snapshots to FTP
HOST='ftp.xxxx.de'
USER='44xxxx333'
PASSWD='xxxxxx'
LOCALPATH=/home/fa/domoticz/smbfiles/ipcam/$today
FILE=*.jpeg
DIR='ipcam/'
FTPFOLDER=$today #Create a new folder on ftp with timestamp
ftp -n $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
passive
cd $DIR
mkdir $FTPFOLDER
cd $FTPFOLDER
lcd $LOCALPATH
mput $FILE
quit
exit;
EOF
fi
I could not figure out why these problems occur:
1. Only one, two or three pictures make it to the FTP server. Instead of 10. The FTP log gives me this without error but only two files transfered:
Code: Select all
250 OK. Current directory is /ipcam
257 "01-02-2017__21-08" : The directory was successfully created
250 OK. Current directory is /ipcam/01-02-2017__21-08
Local directory now /home/fa/domoticz/smbfiles/ipcam/01-02-2017__21-08
mput 01-02-2017__21-08-30.jpeg? 200 PORT command successful
150 Connecting to port 27380
226-File successfully transferred
226 12.972 seconds (measured here), 20.75 Kbytes per second
277031 bytes sent in 11.00 secs (24.6055 kB/s)
mput 01-02-2017__21-08-36.jpeg? 200 PORT command successful
150 Connecting to port 24601
226-File successfully transferred
226 7.986 seconds (measured here), 33.97 Kbytes per second
279261 bytes sent in 6.77 secs (40.2830 kB/s)
mput 01-02-2017__21-08-41.jpeg? mput 01-02-2017__21-08-56.jpeg? 221-Goodbye. You uploaded 541 and downloaded 0 kbytes.
221 Logout.

What can be the reason for this? Something wrong in my script? I already tried in passive mode. But same problem.
Hope someone has a solution.
ED
P.S.: I just tried to upload one of the "broken" pictures. But the board software can not handle the file either and refuses
