The answer in How to open a new Firefox window with URL argument is broken in Mac OSX Mountain Lion (10.8.2). I can't comment on that answer or question, so I had to create a new question.

It fails like this:

$ firefox-window http://www.yahoo.com
dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/osascript) is code signed with entitlements

The new window opens successfully, but it's empty (i.e. the environment variable passed to the AppleScript in the bash function is ignored).

Is there an alternate way to pass variables to applescript from the commandline? (perhaps not using bash?)


"A sandboxed app can’t use AppleScript to communicate with another app on your Mac, unless the developer specifically requests (and receives) an entitlement to do just that."

So I'm guessing that this restriction prevents the technique used above, i.e. a bash script can't wrap an applescript that talks to firefox.

workaround #1

Call it directly instead of using the shell variable ($1). For example, this works:

$ osascript ~/bin/firefox-window.scpt "http://www.yahoo.com"

Firefox opens a new window pointed at yahoo.

  • Interesting. This is a "security feature" related to Gatekeeper in 10.8 and has been reported already. I'm not sure there's a fix yet. I reworded and generalized your question a little, otherwise it'd be a duplicate of the one you linked to. I hope someone has a workaround for this, then I could also update my answer on the first question. – slhck Nov 5 '12 at 13:46
  • thank you! I saw a couple questions pertaining to the security feature, and I understand what they are trying to prevent by enforcing it this way, but the workarounds so far show applescripts that don't have any variable input. My second guess is to rewrite the function in pure applescript and pass vars in from the command line instead of using env vars, but I'm still working that out. – Larry Kyrala Nov 5 '12 at 13:54
osascript -e 'tell application "Firefox"' -e 'open location "http://example.com/"' -e 'end tell'

That should do it, in a new tab, not a new window, if that's okay.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.