Last active
March 28, 2020 04:58
-
-
Save wkw/01dab92afaf95ec3f83ec1e11431ec9c to your computer and use it in GitHub Desktop.
Mac OS Get Wi-Fi IP address (cmd line or php)
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
<?php | |
# SOURCE: https://apple.stackexchange.com/a/226880 | |
$ip = trim(exec("ipconfig getifaddr $(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/{getline; print $2}')", $out, $rc)); | |
echo "$ip\n"; |
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
#!/usr/bin/env bash | |
# SOURCE: https://apple.stackexchange.com/a/226880 | |
ipAddress="$(ipconfig getifaddr $(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/{getline; print $2}'))" | |
echo "Wi-Fi IP = $ipAddress" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment