Running Shell-commands in Apache/php-problem

soul8o8

Registered
Hi!

I'm playin around with the apache web server on osx and now I've run into an annoying problem.

I have a PHP-script that calls a shake batch render like

exec('shake render file.shk');

The problem is that when I power up the computer and log in and open up my php-page that runs the shake renderer, the shake renderer reports errors. Basically it says that the function "xyLayer" is unknown. (xyLayer is a function that normally works in shake.) Also the variable $HOME is set to nothing. Bottom line is, shake halts.

Now here's the annoying part: If I open system preferences and select file sharing and then select the "personal web server" (apache) and just shut it down and start it again - everything works fine!! shake finds the function "xyLayer" and $HOME is set to the appropriate folder.

Well, my question is - how do I make apache work without having to restart it?

I'm thinking that maybe this is all because apache is started at boot-time and at that time $HOME is unset and maybe shake needs stuff like that to work properly or something. What can I do? (of course I can easily replace the $home variable with my own variables, but stil, that wont make shake work..)



does anybody know a GUI for apache on osx?

/soul8o8
 
You can use the 'e' flag to ps to check the environment of a running program. If you think it's a missing environment variable at startup time, compare the initially started apache process's environment, with that of the restarted process. Find the master apache process id, then run something like

ps ewwp (apache's pid)

Then restart apache and do it again...
 
..thanks for the fast reply scruffy! :) very useful!

ok, I finally solved it. I tought I'd just post it quickly here for future reference..

Turns out "xyLayer" was a 3rd party plugin and shake probably needed the env-vars from the current user to find it (i'll try your method later scruffy..) - anyway, the plugin consist of two header files one "xyLayer.h" and one "xyLayer_UI.h" in the 3rd party folder. I opened the shake.app-folder (ctrl-click Shake and select "show contents of package" or similar) and then put "xyLayer.h" in "contents/plugins/startup/" and "xyLayer_ui.h" in "contents/plugins/startup/ui/" - now the plugin is part of the shake's default setup and is always present. neat. :)

i also deprecated all use of $HOME variables as the server must be able to run without any use of $HOME variables...


hi-5
/soul8o8
 
Back
Top