1
0
Fork 0

Add ssh-retry

This commit is contained in:
Starbeamrainbowlabs 2017-05-09 18:34:45 +01:00
parent 368bc2a011
commit 8658210969
2 changed files with 25 additions and 0 deletions

View File

@ -53,6 +53,7 @@ Here's a list of the most interesting ones, along with what they do and where th
- [shellshare](https://shellshare.net/) - A live terminal broadcasting utility.
- [colortrans](https://gist.github.com/MicahElliott/719710) - Convert rgb colours to xterm ones
- nautilus-here - A quick command that opens nautilus in the current directory. For lazy people :P
- ssh-retry - I forget where it came from, but this command reepeatedly calls ssh until it succeeds in connecting.
## Disclaimer
I don't own many of the tools in this repository. If you are an owner of one of these tools and I haven't linked to you, please let me know as I probably forgot.

24
ssh-retry Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Check we've got command line arguments
if [ -z "$*" ] ; then
echo "Need to specify ssh options"
exit 1
fi
# Start trying and retrying
((count = 100))
while [[ $count -ne 0 ]] ; do
ssh $*
rc=$?
if [[ $rc -eq 0 ]] ; then
((count = 1))
fi
((count = count - 1))
done
# Print a message if we failed
if [[ $rc -ne 0 ]] ; then
echo "Could not connect to $* after 100 attempts - stopping."
fi