Mac OS X network locations and the command line
Problem: I have a bunch of “workflow” wrappers to svn, but I’ve foolishly hardcoded my svn server to svnserver.local, its name on the Bonjour network. So I go home, and on the same laptop I use at work, I have to do 86 extra steps to use my scripts. Wouldn’t it be great if the scripts knew how to figure out if I was at home?
Complication: Airport at home and office are configured essentially identically, so it’s not like I can just look at the IP address.
Solution:scselect! It’s important to note that calling it w/o options prints to STDERR not STDOUT. No idea why.
Anyway after some messing around with things I ended up with this:
scselect 2>&1 | egrep “\*” | tail -1 | awk ‘{print $3}’ | sed -e ’s/(//’ -e ’s/)//’
This returns the current network location. Configure (and switch to) the appropriate network location, and now my wrappers know which repository URL to use. Yay.
Now someone please tell me there’s an easier way ….



