Skip to content

Instantly share code, notes, and snippets.

@Dreyer
Last active April 27, 2024 20:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Dreyer/161b920f0d8300ed3bc750ae2f80c339 to your computer and use it in GitHub Desktop.
Save Dreyer/161b920f0d8300ed3bc750ae2f80c339 to your computer and use it in GitHub Desktop.
Check the status of a NordVPN connection from your shell.
#!/bin/bash
URL='https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data'
JSON=$(curl -s $URL)
printf "\n"
#echo $JSON | python -m json.tool
echo $JSON | python -c 'import sys, json; data = json.load(sys.stdin); print "IP: %s (%s)\nStatus: %s" % (data["ip"], data["isp"], "\033[32mProtected" if data["status"] is True else "\033[31mUnprotected");'
printf "\n"
@ClouDevops101
Copy link

@leogout
Copy link

leogout commented Apr 27, 2024

Updated for python 3

#!/bin/bash

URL='https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data'
JSON=$(curl -s $URL)

printf "\n"
echo $JSON | python -c 'import sys, json; data = json.load(sys.stdin); print("IP: %s (%s)\nStatus: %s" % (data["ip"], data["isp"], "\033[32mProtected" if data["status"] is True else "\033[31mUnprotected"));'
printf "\n"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment