I had a few problems with this - my Snow Leopard system has an extra line with IPv6 info that I don't think the Perl script was expecting so I had to modify the Perl script to look for 3 lines of context instead of 2.
# if Ethernet ipaddress is not present get wireless ipAddress
if ( length($ipAddress) < 1 )
{
- $ipAddress = `ifconfig | egrep -C 2 'en1:' | grep 'broadcast' | awk '{print $2}'`;
+ $ipAddress = `ifconfig | egrep --after=3 'en1:' | grep 'broadcast' | awk '{print $2}'`;
chomp $ipAddress; home
}
The other thing that tripped me up is that the default status string given ("%_ipstatus{@Work,10.*, Available,192.168.*}") could be improved. I was at home and my IP address happened to be 192.168.1.101 -- this actually matches the "10.*" regex and so therefore it thinks I'm at work. I suggest adding caret symbols to the regexes so the matches are a little tighter -- e.g.:
# by msabramo on 11/02/10 at 22:57:46
marca@ladyproud-lm:~/Library/Application Support/Adium 2.0/Scripts/IPStatus.AdiumScripts/Contents/Resources$ diff -u /tmp/IPStatus.AdiumScripts/Contents/Resources/getStatus.pl getStatus.pl
--- /tmp/IPStatus.AdiumScripts/Contents/Resources/getStatus.pl 2009-01-29 21:01:08.000000000 -0800
+++ getStatus.pl 2010-11-02 15:53:22.000000000 -0700
@@ -6,13 +6,13 @@
#print $inputText."n";
# Get Ethernet IP Address
-my $ipAddress= `ifconfig | egrep -C 2 'en0:' | grep 'broadcast' | awk '{print $2}'`;
+my $ipAddress= `ifconfig | egrep --after=3 'en0:' | grep 'broadcast' | awk '{print $2}'`;
chomp $ipAddress;
# if Ethernet ipaddress is not present get wireless ipAddress
if ( length($ipAddress) < 1 )
{
- $ipAddress = `ifconfig | egrep -C 2 'en1:' | grep 'broadcast' | awk '{print $2}'`;
+ $ipAddress = `ifconfig | egrep --after=3 'en1:' | grep 'broadcast' | awk '{print $2}'`;
chomp $ipAddress; home
}
The other thing that tripped me up is that the default status string given ("%_ipstatus{@Work,10.*, Available,192.168.*}") could be improved. I was at home and my IP address happened to be 192.168.1.101 -- this actually matches the "10.*" regex and so therefore it thinks I'm at work. I suggest adding caret symbols to the regexes so the matches are a little tighter -- e.g.:
%_ipstatus{@Work,^10.*, @Home,^192.168.*}