I’ll start my question like many others. I am new to AppleScript, I just started today.
I’ve used a lot of samples of code on here and other sites to write an AppleScript which gathers a load of system information (serial number, computer name, logged on user, ram etc) and I am able to write that information to a MySQL database.
I would like this to run when a user logs on to the workstation. Where do I put it, how do I reference it? I’ve read something about launchd but I don’t know how this works.
If I can’t do it when users logon then I would like to try and schdule it instead. How would I deploy that without having to visit 300 Apple Macs?
I use a Windows PC tool called BGInfo to gather system information into the MySQL database. I decided to write this script to add the Macs to the same database and not keep them separate. I am at home now but I will post my script tomorrow if anyone is interested.
Read this: http://macscripter.net/viewtopic.php?id=24748
Create a text file named com.paul.applescript_Launchd.plist and place it in “/Library/LaunchAgents”
<?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">
Paste the text above into the file and edit this line to point to the script you want to run:
thanks for your reply. I’ve tried all sorts of plists with LaunchAgents and LaunchDaemons and obviously haven’t got the syntax correct. I had saved the script as an Application and in combination with my and your plists wouldn’t work. Simplifying by just leaving it as a script and using your plist now works.
The old way I monitored the Console logs and got weird errors like:
“Job failed to exec(3) for weird reason: 2”
I discovered my applescript wasn’t cross OS version compatible. I had (accidentally) put some:
set variablename to computer name of (system info)
within a try end try statement which 10.7.5 was happy with but 10.8.2 threw up some odd errors until I discovered my error.
Once I put the statements in the right place your code below worked.
Thanks for helping.
Why don’t you just add the app to your startup items?