Using Launchd for an Applescript Application

1

1

I created an Applescript Application (called Print Release) that runs without issue (code below):

do shell script "rm -R /Users/<account>/release.zip; rm -R /Users/<account>/release; curl -L https://URL/to/webserver/release.zip -o /Users/<account>/release.zip; unzip -o /Users/<account>/release.zip -d /Users/<account>; rm -rf /Users/<account>/__MACOSX; /Users/<account>/release/pc-release-mac.command --config config.properties"

I'm now trying to create a plist file (called com.papercut.release.agent.plist) so I can have it run at load and automatically restart if a user closes the program. When I load the plist file (written below) using terminal, I get a "No such file or directory" error.

<?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.papercut.release.agent</string>
      <key>ProgramArguments</key>
      <array>
          <string>/Applications/Print Release.app/Contents/MacOS/Application Stub</string>
      </array>
      <key>RunAtLoad</key>
      <true/>
      <key>KeepAlive</key>
      <true/>

I'm using the following code to try to load the plist file using Terminal:

launchctl load com.papercut.release.agent.plist

I also tried:

launchctl load /Library/LaunchAgents/com.papercut.release.agent.plist

It would be great if I could have the application only run at load and keep alive for 1 specific account and not all accounts, but I'm not sure how to do that.

Any help would be greatly appreciated.

krees

Posted 2017-09-11T19:15:38.787

Reputation: 33

Save com.papercut.release.agent.plist in ~/Library/LaunchAgents. Then cd into that directory and run launchctl load com.papercut.release.agent.plist, and see if that works. – CJK – 2018-01-27T21:50:41.287

No answers