0

I have an exec() command on my code which runs an applescript from the desktop

$cmd = "osascript /Users/***/Desktop/script.app";
exec($cmd, $output);
print_r($output);

On one computer it runs without errors, on the second computer it returns an empty array. They are exactly at the same directory, except the username which I change it to the correct one. I also checked the file permissions.

I would appreciate it if someone could shed some light on this one.

1
  • @MarkSetchell for some reason one machine cannot load the applescript from the file. If I write the script inside my code it works perfectly. Your answer was helpful though Commented Feb 16, 2019 at 11:28

1 Answer 1

1

The PATH that scripts get exec'ed with may be different on the two machines.

The executable osascript lives at:

/usr/bin/osascript

I guess the machine that works includes /usr/bin in the PATH, and the one that doesn't work doesn't include it.

TL;DR

Give the full path:

$cmd = "/usr/bin/osascript /Users/***/Desktop/script.app";
exec($cmd, $output);
Sign up to request clarification or add additional context in comments.

Comments

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.