#!/usr/bin/perl # dave stevens # http://idav.es/ # script to turn off airport for a given amount of time :) use Time::Local; # READ ME # THIS WILL ONLY WORK IF YOU ARE AN ADMINISTRATOR!!! # you will need to modify this file before you can use it # open terminal, Applications | Utilities | Terminal # you will need to then go to the directory where this file is # when you open terminal it should be in your home folder # if you saved the file in your Downloads directory you should type # "cd Downloads" # (cd is change directory), you need to get to where the file is # once there you need to run the following command # "sudo perl getofftheinet.p " # where is the number of minutes you want the internet # to be disabled for. # this should ask you for a password, this is your password # once entered it should tell you that it has disabled the airport # you are now off the internet for the time you specified :) # this is the device name for the airport on most macs # to make this work on ethernet try "en0" $device = "en1"; $minutes = $ARGV[0]; if(!($minutes)) { exit(0); } $end_time = time() + ($minutes * 60);; while(time() < $end_time) { if(readpipe("ifconfig $device") =~ /status:\sactive/) { # turn device off print "Turning off the internet\n"; system("ifconfig $device down"); } sleep(10); } # then turn it back on at the end :) system("ifconfig $device up"); print "Turning the internet back on\n"; exit(0);