Skip to content

Instantly share code, notes, and snippets.

@wkw
Last active March 28, 2020 04:58
Show Gist options
  • Save wkw/01dab92afaf95ec3f83ec1e11431ec9c to your computer and use it in GitHub Desktop.
Save wkw/01dab92afaf95ec3f83ec1e11431ec9c to your computer and use it in GitHub Desktop.

Revisions

  1. wkw revised this gist Aug 10, 2017. 2 changed files with 8 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions macos-get-ip-address.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    <?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";
    6 changes: 6 additions & 0 deletions macos-get-ip-address.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #!/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"
  2. wkw revised this gist Aug 10, 2017. No changes.
  3. wkw created this gist Aug 7, 2017.
    3 changes: 3 additions & 0 deletions macos-get-ip-address.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    <?php
    $ip = trim(exec("ipconfig getifaddr $(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/{getline; print $2}')", $out, $rc));
    echo "$ip\n";