Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 Transmission.app in a Mac.

share|improve this question

migrated from stackoverflow.com Sep 2 '11 at 9:04

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

Abarnert's answer at stackoverflow.com/questions/11532144/… 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

1 Answer 1

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.