Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Operating System (http://www.mac-forums.com/forums/os-x-operating-system/)
-   -   Applescript/Automator turn off internet (http://www.mac-forums.com/forums/os-x-operating-system/258516-applescript-automator-turn-off-internet.html)

bassguy86 11-26-2011 03:56 AM

Applescript/Automator turn off internet
 
I have satellite internet due to where I live. I have unlimited download/upload from 1-6am and am backing up my mac to a cloud server. I want to set my laptop to turn off wifi at 6am so I do not use up my limit (250mb/day).
Is there an applescript or automater I can use for this? thanks for any help.

I know I can just set the computer to shut down then but have had firefox and other programs at times lock up (not in a long time though) and stop the computer from shutting down.

MacsWork 11-26-2011 09:10 AM

This hint will show you how to disable/enable the Airport of your Mac.
Enable and disable Airport from the command line - Mac OS X Hints

Then use an Automator action to run a shell script with those commands, and then schedule those Automator Applications with iCal to run at 6:00AM and maybe 6:15AM to re-enable.

The problem you will face is running sudo commands unattended. Which is not a good practice.

This thread will go over some methods (with obvious security concerns) as well as methods to limit damage.
Shell script sudo without password prompt under Darwin? [Archive] - The macosxhints Forums

brandonjp 09-23-2012 01:10 PM

FYI, you can also enable/disable the airport/Wi-fi without sudo using:

Code:

networksetup -setairportpower en0 off
or
Code:

networksetup -setairportpower en0 on
I put it in an Automator workflow > Run shell script. Add other stuff to the workflow if needed, then save as Application or Service (to use a hotkey).

* Note: You might need to change the "en0" part to match whichever network device you're wanting to affect. Get a list of all devices with:
Code:

networksetup -listallhardwareports
I'm using OS X Mountain Lion 10.8.2 - The commands might be slightly different on other OS versions. This page has some info:
http://macstuff.beachdogs.org/blog/?p=44


All times are GMT -4. The time now is 07:29 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.