Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Run AppleScripts on a Mac using Remote.app iOS devices
While the iTunes Remote for iPhone app from Apple is very cool many of us are still waiting for a script editor to make it's appearance on iOS. This AppleScript will allow you to run specific pre-written scripts on your Mac from your iPhone, using iTunes as an intermediary.

First create a stay open application from this script in the AppleScript Editor and add it to your Login Items in the Accounts pref panel:
on idle 
 tell application "iTunes"
  try
   copy comment of current track to tehscript
   copy name of current playlist to tehlist
   if tehlist = "scripts" then
    if player state is playing then
     pause
     do shell script "osascript -e '" & tehscript & "'"
    end if
   end if
  end try
 end tell
 return 5
end idle
Then create a new playlist in iTunes called Scripts. Be sure to share that playlist in iTunes. Now make a short (~8 seconds no shorter then 5) sound file, using GarageBand, Audacity, or your favorite sound editing application.

To add a script, modify the name of the sound file in Finder (so iTunes will add it a second time) and drag it into iTunes. Then type your script into TextEdit and copy it into the comments of your sound file in iTunes. You can then use the Remote app from your iOS device to connect to the shared music library on your Mac and select the track in the Scripts playlist.

Note there is no way (that I know of) to send anything to the scripts from your iPhone (other than simply executing them).

[crarko adds: I tested this, and it works as described. I uploaded the script and a sample sound file provided by the author here. This seems more of a curiosity to me but I'm sure some enterprising scripter will make use of it.]
    •    
  • Currently 3.44 / 5
  You rated: 4 / 5 (9 votes cast)
 
[9,768 views]  

Run AppleScripts on a Mac using Remote.app | 12 comments | Create New Account
Click here to return to the 'Run AppleScripts on a Mac using Remote.app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Run AppleScripts on a Mac using Remote.app
Authored by: asmeurer on Oct 12, '10 09:22:38AM

There are thousands of apps in the App Store. You mean to say that there aren't any that can remotely run an AppleScript better than this hack?



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: allanmarcus on Oct 12, '10 11:49:58AM

yes, any VNC or SSH can do it. This is just another way.



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: SuperCrisp on Oct 12, '10 11:59:35AM

You can also execute scripts embedded in a webpage served from the machine, and you can also execute scripts from iChat running on that machine. Of those, the one that would probably be easiest on an iPhone or other iOS device would be the webpage, as it'd require less typing. I prefer terminal shortcuts myself. NB: be careful how accessible you make this target machine to the outside world.



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: prijker on Oct 12, '10 09:25:04AM

Does it sound like a security breach in MacOSX?



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: Snaro on Oct 12, '10 11:34:19AM
There may be a very limited possibility for abuse. But consider the conditions that have to be met before someone can actually do something malicious:
  1. There must be a special script running. This is not a built-in: you have to provide it
  2. There must be a playlist titled "Scripts"
  3. Within this playlist, there must be songs that contain the actual script code in the comments. Again, these can't be inserted remotely, you have to include the script code in your local song files.
  4. A possible attacker must have access to your WiFi and his iDevice must be paired with iTunes
I doubt very much that this can be considered a security breach.

[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: lar3ry on Oct 12, '10 11:45:34AM

Of course not. You have to manually create the playlist as well as the stay-open application script as well as setting it in your login items list. And then you need to create the Applescript to run and attach it to a song file in that playlist.

That's a pretty big bunch of ifs that you need to manually perform.

Wouldn't it just be easier to write the malicious script as the "stay-open application script" and put it in your login items? You'd omit a lot of ifs and thens and get a faster bang on your buck for maliciousness, wouldn't you?

A security hole isn't when a user shoots him- or her-self intentionally in the foot. It's when somebody else injects a rifle into the system and then has the gun automatically go off. (In other words, "rm -rf /" isn't a security hole if a user types it as root; it's a security hole when simply launching an application as a user without privileges and has the app open up a root session and executes that command which is the security hole.)

lar3ry



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: allanmarcus on Oct 12, '10 11:53:12AM

no, it doesn't. First you need to have access to set up the scripts. Then you need to share you iTunes library. Then you need to know the code to access the itunes library.



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: designr on Oct 12, '10 02:18:14PM

Couldn't you just set up an Applescript trigger in Mail using Rules? Then send yourself an email to trigger Mail to run the Applescript?



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: MurphyM on Oct 12, '10 06:40:07PM

That's how I prefer to run scripts from my iPhone. Works over 3g too, obviously. I have a bunch of posts on my site (Murphy Mac) about kicking off scripts through mail - including one for rotating photos taken in portrait view with the iPhone. So people see them correctly in their browser.

I still think this hint is very interesting. Once set up it could be considered quite user friendly. It could provide a list of possible commands instead of you having to remember the choices.



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: zoff on Oct 17, '10 07:14:44AM

If you have QuicKeys, the QuicKeys Anywhere app can remote control QuicKeys.



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: mhopeng on Apr 24, '11 12:24:12AM

What a great hint! It allows me to execute applescripts to control the stereo which is playing music from iTunes on the computer, all while using Apple Remote. Thanks for sharing!



[ Reply to This | # ]
Run AppleScripts on a Mac using Remote.app
Authored by: bluedoraemoncat on Aug 18, '12 01:53:54AM

For the benefit of googlers you can kick off AppleScripts nicely now on your Mac from your iOS device using EventScripts Mobile



[ Reply to This | # ]