Created
April 29, 2014 12:08
-
-
Save bankair/11398290 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function get_free_port_starting_from() { | |
| local PORT=$1 | |
| local QUIT=0 | |
| while [ "$QUIT" -ne 1 ]; do | |
| lsof -i :$PORT> /dev/null | |
| if [ $? -ne 0 ] | |
| then | |
| QUIT=1 | |
| else | |
| PORT=`expr $PORT + 1` | |
| fi | |
| done | |
| echo $PORT | |
| } | |
| function assh() { | |
| local PORT=`get_free_port_starting_from 2000` | |
| autossh -M $PORT -t $@ | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A bash function that find itself a free port to launch autossh
Usage:
assh [ssh parameters] [ssh host]