Yesterday in my previous post on a Anti-Robber Script I mentioned how you can run your script through email. This post will hopefully teach you the simple way of controlling your Mac remotely over the Internet. This is designed so you can quickly tell you computer when you are at work to do specific tasks without the need for logging in via SSH or some complicated method. Although you can only do basic things with this tip, it is simple to perform and doesn’t take long to learn, or much technical know how.
The first thing to do is set up your scripts to run. These scripts can range from complex scripts such as opening programs, setting up your computer for your return. Basically anything you want. The only limit is your imagination and the scripting language you use. For example you could set up a script to shut down you computer. If you open up Script Editor in the Applications folder and type the following.
tell application "Finder"
That will shutdown your computer. You can change “shut down” with “restart” or “sleep”. One fun one to play is to set up a script to play iTunes as loud as possible. Scare anyone who is at home. You can pretty much do anything you want. The script must be an Apple Script to work.
Configuring them in Mail is the interesting part of this post. You will have to make your Mail rule complicated so it doesn’t get triggered if a normal email pops in. You would wonder what the hell is going on. On the other hand you don’t want to make it so complicated that you can never remember the syntax and trigger the event. A good method I have found is the following.
Open up Preferences > Rules and add a rule rule with the appropiate button.
Set the If statement drop down to all. Set the drop down box to “Subject”, and “Contains” to “Is Equal Too”. Then set the variable to a subject that corresponds the the script you want to run. Start the message with an unused character. For example any of the following would suffice: !@£$%^&*. Most messages will not start with them so you would be safe to include them. Again, make it unique enough so it won’t get triggered accidentally, but not to complicated.
Continue by adding two more rules. These should be message content, and from email address. In the second section, perform the action of opening your Applescript, making sure you link correctly to the AppleScript file. You should end up with something that looks like this:
You are done. Test out your rule to make sure it works. You can now continue to make your rules as you see fit.
I mentioned in the previous post about a script that will give you images of your thief. Originally it needed a web server, but this section will explain how to convert this script to run from email only.
First download the script. You download it from the link below.
Open the script in text editor and delete everything above the comment where it says “The Business End Of The Script” but make sure to leave in the “robber”, “the date” and “path” variable. To finish off delete the end of the if statment at the very end of the document. Then save this file. Refer to the previous post on how to do this. Next open up the Script Editor again and type the following.
do shell script "path/to/script/scriptname.sh"
Save out the script. You can then proceed to make a rule in Mail to run this script. One tip, make the message you send to yourself seem normal and not obvious in that it runs a script.
I hope you have found this post useful in enabling you to control your Mac with email. It is simple to do. With a bit of time and effort you can get your Mac doing all sorts of things remotely. In the mean time I am going to have a play and see what I come up with.
If you want some futher reading I recommend Take Control of Apple Mail and AppleScript: The Definitive Guide. They are both good books which can help you expand your knowledge of Applescript and Mail.