Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created an applescript application (in automator) to open ssh urls. The application is bound to the ssh:// url.

I've got a lot of user@host.inetloc files and search these in spotlight. Selecting the file from spotlight opens the associated application, but i cannot figure out what the filename is which triggered the opening of the application.

It works if i add the "get selected finder items" action and open the .inetloc file from the finder.

I've searched the net and the applescript reference, but it's just too specific.

share|improve this question
How exactly is your app bound to ssh URLs? Info.plist hacking? – kopischke May 25 '12 at 8:25
It's bound by using the "Deault Apps" preference pane. – michiel May 29 '12 at 6:07
And is it bound to the ssh protocol (i.e. on the URL tab of RCDefaultApp) or to the .inetloc file extension? – kopischke May 30 '12 at 15:00
It is bound to the protocol – michiel May 31 '12 at 6:12
OK, getting closer. Could you post details of what the Automator app does when called (workflow actions with respective settings, script contents if there are script actions), please? I think I may have an answer for you, but I could be wrong and need to check the specifics. – kopischke May 31 '12 at 6:39

Would something like this work for you:

on run argv
    set theFile to (item 1 of argv)
    set theFilePath to quoted form of POSIX path of theFile 
    -- your script using the parameters follows
end run

You could skip the first line and just pull off the path if you don't need to use the file itself later in the script.

Also, you'll really want to get ASObjC Runner to parse files and paths easily.

share|improve this answer
Would this work if you're creating an application from Automator? I read somewhere that "on run argv" only works when you run your script with osascript. I'm trying to create an application which can be bound as open action to .inetloc files – michiel May 29 '12 at 6:18
I don't honestly know with the latest automator. This is the only way I know to parse arguments, so you might want to test it before assuming it works. I prefer shell for this sort of job so that's what I typically use. – bmike May 29 '12 at 14:45
It's not the problem how to parse the path/file but where it's being passed from spotlight to the application :-) – michiel May 31 '12 at 6:13

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.