I'm writing a script that SSH into a device, SCP a file over, names it according to the device name and then goes on to the next one. My problem is if a device is not reachable the script hangs forever. Here's my code:
#!/bin/bash echo "Starting Backup of Ubiquiti Radios" #cut -d' ' -f2 /usr/tmp/Script/Links.csv #cut -d' ' -f1 /usr/tmp/Script/Links.csv while read one two; do if sshpass -p 'supersecretpassword' scp -o StrictHostKeyChecking=no control@"$two":/tmp/system.cfg /mnt/hgfs/Ubiquiti/$one.cfg; then echo $one Success! else echo $one Failed fi done < /usr/tmp/Script/Links.csv
It works as is, but the timeout I used canceled the script as a whole, not skipping to the next device. Any ideas would be greatly appreciated.