This is the personal blog of Neil Ang. Simple and interesting technology articles written by a developer for developers. Feel free to comment on posts or link to this site. Constructive feedback is always welcomed.

Dynamically set network location in Mac OS X

Posted: 24 January 2007

I love macs, but sometimes things could have been implemented better. In particular, I hate having to set the network location on my laptop when I go between work and home every day. I have put together a small shell script which can do this. I run this script on startup and it just checks what day and time it is so it can switch between two profiles (work or home).

#!/bin/bash

day=`date +"%a"`
hour=`date +"%H"`

if [ $day = "Sat" -o $day = "Sun" ]; then
  `scselect Home`
else
  if [ $hour -gt 8 -a $hour -lt 16 ]; then
    `scselect Work`
  else
    `scselect Home`
  fi
fi

exit 0

Your comments

No comments have been made. Why not be the first?

Post a comment

Comment Guidelines

  • Have no more than 2 links, otherwise your comment will be flagged as spam.
  • Links are automagically generated.
  • <em>text</em> to make text italic.
  • <strong>text</strong> to make text bold.

JavaScript needs to be enabled to comment.