exec osascript without being prompted for pass

Discussion in 'Mac Programming' started by zbotnik, Aug 11, 2010.

  1. zbotnik macrumors newbie

    Joined:
    Aug 10, 2010
    #1
    Hi all,

    I have a php page that, when loaded, executes an applescript like this:

    PHP:
    exec('osascript "/bs2.scpt"');
    It executes fine, but ones the script has started, and is actually running, I'm prompted for my password, just before the applescript is supposed to do a keystroke via "system events". So the first part of the applescript, which loads a web page, is not affected by this.

    Any ideas how I can avoid this? The webserver is on my own computer, so there's nothing fishy going on!

    Edit: Oh, and the password prompt details says that it's "osascript" that needs the rights to "com.apple.OpenScripting.additions.se"
     
  2. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #2
    I've never looked into something like this but maybe you need to give the user defined to run the webserver executing permissions for osascript ?
     
  3. zbotnik thread starter macrumors newbie

    Joined:
    Aug 10, 2010
    #3
    Might be worth a shot. Any idea how I would do that? I've tried editing the sudoers file, but it hasn't helped. And, would that be the same user running the process httpd? Just in case it isn't the same as the one owning the XAMPP (server) app.
     
  4. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #4
    Same user that runs the httpd process, should just be a simple case of chmod-ing and chowning the osascript binary accordingly.
     
  5. zbotnik thread starter macrumors newbie

    Joined:
    Aug 10, 2010
    #5
    Problem solved. I got around this by first calling a script that uses Applescript Runner to call the next script, like this:

    Code:
    on run {sourcefile}
    	tell application "AppleScript Runner"
    		do script sourcefile
    	end tell
    end run
    executed by using "osascript activatingscript.scpt sourcescript.scpt"
     

Share This Page