Page 1 of 1

Cannot open Firefox via exec( bash script )

Posted: Thu Jan 29, 2009 6:45 am
by snappca
I have written a php app that lets me store bookmarks on my server. Part of this is to capture a screenshot by opening firefox with Xvfb and using import to snag the screenshot. All of that is implemented in a Bash script and works wonderfully. On the PHP side I am simply calling that Bash script using exec, like so:

Code: Select all

# generate thumbnail image of website
exec("/usr/share/scripts/webshot.sh '$url' '$image.png'");
So, here's the problem.....if I were to execute that PHP file from the command line while su'd to www-data (apache user) it works wonderfully. But if I navigate to the same PHP script via a browser I get a screenshot of an empty "desktop".....which makes me think I have some permissions issue executing Firefox.

I've searched, and cannot find any log location to help me troubleshoot this. Any help that could be provided would be greatly appreciated.

Thanks

Re: Cannot open Firefox via exec( bash script )

Posted: Thu Jan 29, 2009 6:14 pm
by snappca
Found out the problem by printing the env command results from both Apache's PHP and the command line. The issue wound up being the HOME environment variable was missing which meant firefox didn't have a default profile to use. I just added export HOME=/var/www to the beginning part of my shell_exec() command.