0

So, I'm trying to write an automator application that runs a simple script.

python Contents/main.py

where Contents is the contents of the .app.

When the script is run it is run in ~ not in the working directory (wherever the file is placed on a system).

Is there a way to do this?

Note: I am not taking any input to the application, you just double click it.

Thanks, Harry

0

You can get the path to Your executable from ps command. You need to know Your app name. Here's my code with EchoPath.app made in Automator:

DIR=`ps x | grep EchoPath | grep -v grep | cut -c 28- `

Sample output:

/Users/slozo/Desktop/EchoPath.app/Contents/MacOS/Application Stub

Application Stub is the default name of the executable created in Automator. Knowing this path You can get the path to Contents dir with dirname command.

3
  • Doesn't seem to work - changed the name and it returns nothing – Harry Beadle Oct 29 '14 at 15:56
  • What is in the file if You do this: echo ${DIR} > ~/Desktop/path.txt after the command I pasted? My path.txt contains correct path. – Mateusz Szlosek Oct 29 '14 at 15:59
  • 1
    I figured it out, it doesn't work when debugging in Automator, but works when the application is run normally. – Harry Beadle Oct 29 '14 at 16:05

You must log in to answer this question.

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