6

I am trying to create an Automator application which I will be distributing to other users on the network. The automator app will be accompanied by a ZIP file and a PKG installer file.

I need to run the PKG installer file the automator app. For this I'm trying to use the Run Shell Script using the following command:

open gdata.pkg

The problem I'm having is that Automator cannot find this file. I think it doesn't pick up the current path. I tried changing it to following ways:

Experiment #1:

cd $@; open gdata.pkg

Experiment #2:

open ./gdata.pkg

Both didn't work for me. Automator keeps giving error that it couldn't run the script. How do I accomplish this here?

My next step after this would be to decompress the accompanied ZIP file onto a new folder on user's desktop.

2 Answers 2

5

Use a Run AppleScript action with the following to get the path:

POSIX path of (path to me)

When run in the workflow, this provides the path to Automator.app, but when run by launching the saved application, this provides the path to the application.

1
  • 1
    Ok that was a good lead. I've managed to develop a code to make it happen: 'set pathToMe to POSIX path of (path to me as text)', and (set script1 to "dirname '" & pathToMe & "'"), and (set dirPath to do shell script script1), then finally (do shell script "open '" & dirPath & "/GData.pkg'"). I'm not sure if this is the best way to make this work. Commented Jan 17, 2015 at 17:02
-3

I'd post the answer here, but this article already fully captures it, so shrug:

http://albertech.blogspot.com/2011/08/get-path-of-running-script-with.html

1
  • 1
    As apt as the article might be, sometimes they get taken offline, so we'd appreciate it if you quoted or paraphrased it here.
    – Tuesday
    Commented Nov 14, 2016 at 4:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .