Reputation: 2967
How do I try an SFTP connection with a heredoc 3 times and catch an error? How do I restructure this to be proper? Error is being thrown on the first semicolon on the last line right before do
count=0; until sftp -o StrictHostKeyChecking=no -i key.pem [email protected] <<END
cd subfolder
END
; do ((count++)); [[ $count -eq 3 ]] && echo 'error' && break && exit 64; done;
Upvotes: 0
Views: 274
Reputation: 88583
Try:
until echo "cd subfolder" | sftp -o StrictHostKeyChecking=no -i key.pem [email protected]
Or take a look at sftp's option -b
.
Upvotes: 1