0

In order to extract data from a website, I would like to open a program that does just this and open a URL inside (!) the running application. I would like to execute this as a shell script.

echo "Launching Program"

#if ["$1" -eq "0"]; then
# Application exited successfully. Restarting.

/Users/Path/to/app/Contents/MacOS/app
open http://www.example.com

#else
# An error occured. Do nothing and exit.
# exit
#fi

This is what I got so far, but this starts the application and opens the URL in a separate browser window. I would like to open the URL inside of the application and also perform other actions with the retrieved data later on. What would be the best way to do that? How can I "interact" and perform actions inside a running application from the command line on Mac OS?

Any hints would be appreciated.

1
  • does open /Users/path/to/app.app http://www.example.com work? Commented Aug 14, 2015 at 14:30

1 Answer 1

2

You can tell open to use something other than the default application for the file to be opened:

open -a /Users/Path/to/app http://www.example.com

Interacting with the program requires that the application be scriptable (generally with AppleScript, but possibly some other scripting language), or more painfully (if the application itself isn't scriptable) using AppleScript to simulate using the GUI of the application.

Sign up to request clarification or add additional context in comments.

2 Comments

You won't need the Contents/MacOS/app bit as open knows how to open .apps.
Ah, right. I didn't really look at the path in the original question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.