[launchd-dev] Launchd sanitizing python environment

Damien Sorresso dsorresso at apple.com
Fri Dec 18 14:06:41 PST 2009


On Dec 18, 2009, at 1:59 PM, Heath Carlisle wrote:
> Hello, I'm a relative noob to launchd. Thanks in advance for any help.
> 
> 10.5.8 , plist run as a User LaunchAgent
> 
> I am running gimp batch jobs via a wrapping python script.
> 
> When I run the wrapper from the command line (bash), all is well. When I
> schedule it via launchd, the environment appears to become sanitized and
> gimp cannot be found.(I'm comparing environments by issuing the "env"
> command from the wrapper script.)
> 
> I can set, for instance, the $PATH via the plist <EnvironmentVariables>
> key,(which will then find gimp) but then other dependant environment
> variables cannot be found, such as the display. Since the display (and
> others) are /tmp/ items, they cannot be "hard-wired" into the plist.
> 
> As gimp requires a host of helpers(X11, GTK+, GEGL, PANGO etc), debuging
> these one env variable at a time seems monumental.
> 
> Is there a way to just run the job as if it were from the user's shell?
> Perhaps I've overlooked some basic concept?


Use `launchctl setenv <name> <value>` from within your Python script.

See launchctl(1) for more.
-- 
Damien Sorresso
BSD Engineering
Apple Inc.



More information about the launchd-dev mailing list