sudo apt-get install sshpass
#!/bin/bash
cd /home/pi/Camcorder/
sudo rm webcam.jpg
sudo rm new-webcam.jpg
raspistill -rot 90 -w 1640 -h 1232 -o "webcam.jpg"
sleep 1
for file in *.jpg ; do
convert "$file" -font "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf" \
-pointsize 22 -fill yellow -annotate +1380+1200 \
%[exif:DateTimeOriginal] "new-${file}"
done
sleep 1
sshpass -p "password" sftp -oPort=22 user@webspace.1and1-data.host:webcam/ <<< $'put new-webcam.jpg'
And run the script with:
$ ./script.sh
Do not run it with an explicit sh as that will ignore the shebang:
$ sh ./script.sh # Don’t do this!
store keys in .ssh: sftp user@webspace