Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9227619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:07:28+00:00 2026-06-18T05:07:28+00:00

I have a little Apple script as follow: beep delay 2 tell application Finder

  • 0

I have a little Apple script as follow:

beep
delay 2
tell application "Finder" to activate

It just makes a sound, wait 2 second and then bring the “Finder” window to the foreground.

When I run it from the command line, it works fine.

Then I want PHP to call that script using the exec() php function.

<?
$cmd = "/usr/bin/osascript \"myscript.scpt\"";
exec($cmd);
?>

It still works fine.

But when I call that same PHP script from the browser, it doesn’t work! The PHP starts, the Apple script starts as well since I can hear the beep sound but its last line is not executed.

I thought that would be an environment variable thing so I made sure they were all the same way as in the terminal:

$cmd = "HOME='/Users/mikael' && … && /usr/bin/osascript \"myscript.scpt\"";

The variables are set properly (as check with env|sort) but still no luck with running my apple script inside a php script displayed in the browser and using the standard MacOS apache stuff.

Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:07:29+00:00Added an answer on June 18, 2026 at 5:07 am

    When osascript runs from PHP, through the web server, it’s not running with a login context, so it can’t send Apple events to applications running on the desktop (like the Finder). You’ll find that a similar issue arises if you try to use osascript over SSH.

    Login contexts are a complex, poorly documented area of OS X. You may want to get your hands on a copy of Amit Singh’s Mac OS X Internals: A Systems Approach if you want to learn more about them.

    If you don’t, though, the answer is generally pretty simple: don’t depend on osascript working correctly from the web server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this little script to toggle a contact form when a button is
I have a working little application made in Groovy. At the moment I can
I have written a little script which retrieves pictures and movies from my camera
I have a little PHP script that sends Push notifications to multiple devices. The
I have a problem that i can't solve, i have a little application that
I have little Lotus Script or Notes/Domino knowledge but I have a procedure, copied
Ok, I have created a little utility with AppleScript and used Automator to turn
I have little unusual problem to solve. I need some hint or links to
I have little bit longer question for you - but hope answer will be
I have little question about how web browser retrieve webpage? I know this User

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.