LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to execute firefox on linux from a php script? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-execute-firefox-on-linux-from-a-php-script-740985/)

Mike123456 07-18-2009 06:38 AM

How to execute firefox on linux from a php script?
 
Hello,
I would like to have a php script that will start firefox on the server where it's running. I need this because I am using a command on firefox to create thumbnail for the opened page.

Currently, if i am using this command from the command line, it is working: "/usr/lib/firefox-3.0.7/firefox -savepng http://www.site-name.com/ --display=:0.0" and firefox generates my thumbnails and saves it.

If I execute the same command above using shell_exec from php, nothing happens and the returned value from shell_exec is NULL.

I tried giving the php script 777 permision, changed owner to root, nobody, still nothing.

What must I do in order to make a php script to execute firefox?

stress_junkie 07-18-2009 11:27 AM

This sounds a lot like a recipe for a remote execution attack.

Mike123456 07-19-2009 03:33 AM

Hi,
No, no, I can assure you, I'm not interested in atacking no one.

I told in the first post, I want to be able to generate thumbnails for a given URL. And I want this thing to be put on my server, so I can call it from my site. I know about the free/paid services like browsershots and others, and they are great, but i need a fast service and simple service just for my site.

So, I found some resources and articles (i don't know if i'm allowed to post an external link here) to an addon for mozilla firefox that can be installed on linux too and called from the command line. And this command (/usr/lib/firefox-3.0.7/firefox -savepng http://www.site-name.com/ --display=:0.0) starts firefox in the first display, loads the url provided, takes a snapshot of the whole page, saves it in the folder where firefox is configured to save the downloads and then closes the browser.

I have tested this from the command line directly on the server and it worked and from the command shell application in webmin administration panel and it works too. Now, all i need is to make it work from php (or perl, cgi, if needed, but i need to intergrate it eventualy in php.

I've read about shell_exec, exec, pastrhough, and so, but no luck.
I've tried giving the php script other users or group, I even gave firefox on my server the user apache, nothing happened, i can't make the above command to work from php.

Please help.

Mike123456 07-25-2009 02:09 AM

Bump.
Is there no one who can help me? No one knows linux here so he/she could help me?
Please, i need help.

alpha01 07-25-2009 02:24 AM

Have you tried using the back tics? (`firefox`).

You mentioned that you have a command on firefox to create thumbnail for the opened page. Have you tried at cURL/lib to see if you can accomplish this without the need of firefox?

Mike123456 07-26-2009 04:29 AM

Hello,
I tried using the backticks but it had no effect, so I searched on php.net for backticks and there it says that they provide the same effect as shel_exec() does, so since shell_exec() doesn't do what i want to do (as you can see in my first post), niether the backticks work.

I searched for a cURL/lib something that could help me, but the only things i got were just examples of how to use cURL to generate a thumbnail for a website using one of the already existing web-services that do that. But this isn't what i want, I need to have my server setup so I can call it from my site and generate the thumbnails.

Please help and advise.
mike.


All times are GMT -5. The time now is 08:28 PM.