Created
January 15, 2009 16:41
-
-
Save rupa/47475 to your computer and use it in GitHub Desktop.
lan detection
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 | |
| function wireless { | |
| case "$(uname)" in | |
| Linux)/sbin/iwconfig 2>/dev/null | awk -F\" '/ESSID/&&!/NOT READY/{print $2}';; | |
| Darwin)/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk '/ SSID/{print $2}';; | |
| esac | |
| } | |
| function int_ip { | |
| case "$(uname)" in | |
| Linux)/sbin/ifconfig | awk '/Bcast/{ split($2,a,":"); print a[2] }';; | |
| Darwin)/sbin/ifconfig | awk '/broadcast/{ print $2 }';; | |
| esac | |
| } | |
| [ $1 ] || wireless | |
| for x;do case $x in | |
| -h)echo "use: $(basename $0) [-h][-e][-i][-w]";; | |
| -e)curl ip.cutup.org;echo;; | |
| -i)int_ip;; | |
| -w)wireless;; | |
| esac;shift;done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment