Created
July 11, 2022 09:36
-
-
Save codemonkeynumber24/b6ef32c8435bac0f803e260ec15a3c1c 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
#!/bin/bash | |
# Check for user input | |
if [ -z "$1" ] || [ -z "$2" ]; then | |
echo "Expects: getdisplayip.sh \"VPN Interface\" \"Default Interface\"" | |
exit 0 | |
fi | |
VPNIFACE=$1 | |
DEFIFACE=$2 | |
VPNCMD="/mnt/c/Windows/system32/netsh.exe interface show interface \"${VPNIFACE}\"" | |
VPNRES=$(eval "$VPNCMD") | |
DEFCMD="/mnt/c/Windows/system32/netsh.exe interface show interface \"${DEFIFACE}\"" | |
DEFRES=$(eval "$DEFCMD") | |
if [[ "$DEFRES" == *"Getrennt"* ]] && [[ "$VPNRES" == *"Getrennt"* ]]; then | |
echo "Both interfaces are disconnected." | |
exit 0 | |
fi | |
IPCMD="" | |
if [[ "$VPNRES" == *"Getrennt"* ]]; then | |
IPCMD="/mnt/c/Windows/system32/netsh.exe interface ip show addresses \"${DEFIFACE}\"" | |
else | |
IPCMD="/mnt/c/Windows/system32/netsh.exe interface ip show address \"${VPNIFACE}\"" | |
fi | |
IPCMD="${IPCMD} | grep \"IP-Adresse\" | perl -lpe 's/\s+IP-Adresse:\s+(\d+.+?)[\r\n]*\$/\$1:0.0/'" | |
echo $(eval "$IPCMD") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment