3

I am trying to execute an Apple Script from my launchd daemon. My script has just one line and it is given below.

say "Message From Daemon!"

This always fails and throws this error message "File some object wasn't found".

Any idea why this is happening? The same script works properly if I run from xcode (not launching it via launchd) and from any other app that runs in user context.

Seema Kadavan
  • 2,538
  • 1
  • 16
  • 31

2 Answers2

1

Playing sound using NSSound rely on the window server and daemon is not allowed to connect to the window server.

I am assuming same issue with say command. ( This tool uses the Speech Synthesis manager to convert input text to audible speech and either play it through the sound output device chosen in System Preferences or save it to an AIFF file.)

Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
0

I'm guessing you're running into the same problem I had originally when I tried the same kind of thing. The path in your .plist file needs to point deeper into the applescript application. Below is an example of the .plist file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.namespace.script_name</string>
        <key>Program</key>
        <string>/Applications/script_name.app/Contents/MacOS/applet</string>
        <key>LowPriorityIO</key>
        <true/>
        <key>Nice</key>
        <integer>1</integer>
        <key>StartInterval</key>
        <integer>7200</integer>
    </dict>
</plist>
ThrowBackDewd
  • 1,737
  • 2
  • 13
  • 16