Skip to content

Instantly share code, notes, and snippets.

@heyarne
Last active August 23, 2018 09:59
Show Gist options
  • Save heyarne/9a6325149f765151bbcceb26a835dade to your computer and use it in GitHub Desktop.
Save heyarne/9a6325149f765151bbcceb26a835dade to your computer and use it in GitHub Desktop.
Get a random free port on uberspace

Setup instructions

Use ssh to login to your uberspace account, then:

$ wget -O free-port https://gist.githubusercontent.com/heyarne/9a6325149f765151bbcceb26a835dade/raw/1f07b69e62f0c47423acb5cb912482b7d65940f0/free-port.sh
$ chmod +x free-port
$ mv free-port ~/bin
$ free-port
$ # example output: 64477
# /bin/bash
while :
do
RAND_PORT=$(( $RANDOM % 4535 + 61000)); netstat -tulpen | grep $RAND_PORT || break
done
echo $RAND_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment