Running AppleScript via system(), error 256

  app-bundle, applescript, c++, macos, system-calls

I’m having issues running an AppleScript script from my application bundle. I have simple AppleScript script which opens and does "echo hello". If I run this script as

osascript /path/to/script.appleScript

in Terminal all works well. However I need to call this from my C++ utility, where I do the same thing via system call:

const auto result = ::system("osascript /path/to/script.appleScript");

This also works quite well, but my hierarchy is a bit more complicated. On top of this I have application bundle which contains my utility to call the AppleScript script as well as some other daemons and utilities. At some time one of the other utils call my ‘AppleScript c++ util’. However this always fails with error code 256. I’ve tried to call simple bash script instead of my AppleScript script and it worked just fine. If I tried to call osascript from that bash script it again fails with 256.

Any ideas what might cause this? Does the application bundle need some permissions or entitlements?

Source: Windows Questions C++