[X-Unix] My ip address
lj Palmer
darwin at ljsworld.com
Wed Feb 16 16:32:00 PST 2005
I found this sometime back at macosxhints.com
..lj
#!/bin/bash
# A small programme to display ip address information.
#
ifconfig | awk ' \
# Setup some variables
BEGIN { iMedia = 0 ; aMedia[iMedia] = "" ; aIP[iMedia] = ""}
# The next line should find the type of media connected, and store the
name
# in the aMedia array.
((/^...:/) || (/^...."/)) && ($2 ~ /UP/) && ($1 != "lo0:") {
aMedia[iMedia] = $1 }
# The next thing that should be found is the address. (ASSUMPTION!).
Put the result
# in the aIP array.
(/inet /) && ($2 != "127.0.0.1") { aIP[iMedia++] = $2 } END { iCount
= 0;
sMedia = "";
if (iMedia > 0) { while (iCount < iMedia) { sMedia =
"Psychic";
if (aMedia[iCount] == "en0:") { sMedia = "Ethernet";
} if (aMedia[iCount] == "en1:") { sMedia = "WiFi";
} # Display informtion on the media connected.
printf("%-21s%s\n", aIP[iCount], sMedia);
iCount++;
} } else { printf("No media connected\n");
} }'
On Feb 14, 2005, at 16:28, KL Tah wrote:
> Hi,
> Anyone know a slick one-liner in xterm to find out what ip address I'm
> assigned (i.e. Without having to go to System Prefrences)?
>
> Thanks,
> KL
> --
>
>
> _______________________________________________
> X-Unix mailing list
> X-Unix at listserver.themacintoshguy.com
> http://listserver.themacintoshguy.com/mailman/listinfo/x-unix
>
>
..lj
http://public.xdi.org/=lj
More information about the X-Unix
mailing list