I am having troubles with a bash script. I am trying to automate the process of sending files to my raspberry pi through ssh. I want to prompt for a path to a file/directory, then copy it to the /home/pi/push
directory on my pi. I then want to ask if there is another file to send, and if yes then loop back again, otherwise exit the program. I zeroed out the IP address for obvious security reasons.
done=0
while [ $done -lt 1 ]
do
read -r -p "Path to file: " path
spawn scp -r $path pi@000.00.000.00:/home/pi/push
expect "assword:"
send "password\r"
interact
read -r -p "Send another? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
then
$done=1
else
echo "Ending file transfer."
fi
done
If you have suggestions on a better way to achieve this, that would be great as well!