Sorry, I messed up the script. It should have been this: set vars to { ¬ {name:"ANT_HOME", value:"/usr/local/apache-ant-1.9.6"}, ¬ {name:"CATALINA_HOME", value:"/Users/pscott/Projects/apache-tomcat-8.0.24"}, ¬ {name:"LAUNCHD_SCRIPT", value:"/Users/pscott/bin/logon_as"}, ¬ {done:true} ¬ } repeat with i from 1 to (count of vars) - 1 do shell script ¬ "/bin/launchctl setenv " & name of item i of vars & ¬ " " & value of item i of vars end repeat
Paul > By the way, you could also use this AppleScript, saved as an application, and > run automatically via the System Preferences -> Users & Groups -> Current > User -> Login Items configuration. > > set vars to { ¬ > { name:"ANT_HOME", value:"/usr/local/apache-ant-1.9.6" }, ¬ > { name:"CATALINA_HOME", value:”/usr/local/apache-tomcat-8.0.24" }, ¬ > { done: true } ¬ > } > repeat with i from 1 to count of vars - 1 > do shell script "/bin/launchctl " ¬ > & name of item i of vars & " " ¬ > & value of item 1 of vars > end repeat > > That is much easier to set up, but has the disadvantage of bouncing the > application icon in the Dock momentarily at login. The launchd mechanism is > silent, and seems to complete a tad bit sooner. > > Paul > >> On Dec 16, 2015, at 15:47, Rick Mann <rm...@latencyzero.com> wrote: >> >>> I'm working on an OS X app that unfortunately has to call a series of bash >>> and python scripts for part of the processing it does. I was able to >>> include the scripts in my app's bundle, and invoke them there, but the >>> environment is different when launched via my app than when launched on the >>> command line. How can I best control the environment used when executing >>> external scripts? >>> >>> -- >>> Rick Mann >>> rm...@latencyzero.com >> >> >> If you want to have specific environment variables set for all apps launched >> regardless of how they were launched, you can use the launchd mechanism, >> which is compatible with all the latest Mac OS X releases. >> >> You can put this file in ~/Library/LaunchAgents/local.launchdrc.plist >> >> <?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>local.launchdrc</string> >> <key>Disabled</key> >> <false/> >> <key>RunAtLoad</key> >> <true/> >> <key>ProcessType</key> >> <string>Background</string> >> <key>ProgramArguments</key> >> <array> >> <string>/Users/yourusername/.launchdrc</string> >> </array> >> <key>StandardErrorPath</key> >> <string>/dev/null</string> >> <key>StandardOutPath</key> >> <string>/dev/null</string> >> </dict> >> </plist> >> >> Then, create ~/.launchdrc (chmod 755) that looks something like this: >> >> #!/bin/sh >> launchctl setenv ANT_HOME "/usr/local/apache-ant-1.9.6" >> launchctl setenv CATALINA_HOME “/usr/local/apache-tomcat-8.0.24” >> >> Where each environment variable you want available to all launched apps is >> listed. Add variables as needed. This will set up an environment for the >> user at login time that will get picked up by all launched apps, whether run >> from the command line or launched via Finder. >> >> This replaces the old ~/.MacOSX mechanism where you could set environment >> variables at login. >
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com