Cannot open Firefox via exec( bash script )

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
snappca
Forum Newbie
Posts: 5
Joined: Sat Jan 27, 2007 7:32 am

Cannot open Firefox via exec( bash script )

Post 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
snappca
Forum Newbie
Posts: 5
Joined: Sat Jan 27, 2007 7:32 am

Re: Cannot open Firefox via exec( bash script )

Post 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.
Post Reply