LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how do i run firefox using exec() in php? (https://www.linuxquestions.org/questions/linux-software-2/how-do-i-run-firefox-using-exec-in-php-842934/)

vaporizel 11-07-2010 08:34 PM

how do i run firefox using exec() in php?
 
I can run firefox in PHP CLI using this code

Code:

exec("DISPLAY=:0.0 firefox");
but when i run it in BROWSER it didnt give same result, firefox didnt show, even in process.

I'm using Centos 5.4 32-bit

pgpython 11-09-2010 05:46 AM

I think your slightly confused here. When you ran Firefox from the cli you ran it from the machine you were running it on. however if you put that command on a web page. that does not get executed on the client! What happens is the client will request that page and execute on the server. which is a dangerous thing to do and should be only done if necessary and under the tightest security and also is unsuitable for running any GUI commands. so putting exec("DISPLAY=:0.0 firefox") is completely wrong.

So the question you ask is how do you execute the command on the client then?

The answer is you can't under normal circumstances. Fortunately for opening a window you don't need to :). you can use the window.open function in javascript. which will open a new browser window or use the target attribute on links

Be careful if you use window.open though, many browsers will block this as its considered to be annoying popup


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