Created
March 10, 2017 13:52
-
-
Save Dalimil/408acef183cc9d19bd066829d234a91e to your computer and use it in GitHub Desktop.
Get ngrok URL from command line
This file contains 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
# ngrok should be running | |
# replace http with https at the end if needed | |
# based on: https://gist.github.com/rjz/af40158c529d7c407420fc0de490758b | |
echo $(curl -s localhost:4040/inspect/http | grep -oP 'window.common[^;]+' | sed 's/^[^\(]*("//' | sed 's/")\s*$//' | sed 's/\\"/"/g') | jq -r ".Session.Tunnels | values | map(.URL) | .[]" | grep "^http:" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An alternative is to use the ngrok api. see: ngrok agent api - tunnel detail
Pipe the output to
jq
to extract the appropriate value. e.g. to extract the public_url of my https tunnel I run:curl -s http://localhost:4040/api/tunnels | jq ".tunnels[0].public_url"