Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to be able to automatically disable or block traffic from my bittorrent application when I'm connected to WiFi network "A," and automatically enable it when I'm connected to network "B." Is this possible? I'm using in a Mac.

share|improve this question

migrated from Sep 2 '11 at 9:04

This question came from our site for professional and enthusiast programmers.

Abarnert's answer at… demonstrates a more eventful approach to detecting such changes (though nachochab's infinite loop is, perhaps, a less finicky solution). – chbrown Dec 8 '12 at 17:19
up vote 0 down vote accepted

This is how I did it in Lion OSX. Anything that could be improved?

#!/usr/bin/env bash
set -o nounset -o pipefail

while [[ 1 ]]; do
SSID_NAME="$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -e "s/^  *SSID: //p" -e d)"
if [[ $SSID_NAME != $WIFI_NAME ]] ; then

    TRANSMISSION="$(ps aux | grep Transmission | grep -v "grep" | head -n1 | awk '{print $2}')"

    if [[ $TRANSMISSION != "" ]]; then
        kill -9 $TRANSMISSION


share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .