Jump to content

Any chance to run GUI program through exec() ?


hakermania

Recommended Posts

I have an apache server in my Ubuntu laptop and I use PHP.

The server exists to make the communication with my friends possible even if im not in any chatroom or something like this.

 

So, I made a simple php file with enables the outside world to send me a message, but when zeniy, the program that will create the GUI message is ready to take place, I get error the *Display not Found* and such

Even if I execute the command like

DIPLAY=:0 command_Here

i get the same

 

So, is there any way to make exec() run a GUI ?

Link to comment
Share on other sites

If you try to launch GUI apps from a service in Vista, you'll have lots of trouble.  As a security feature, Vista mediates the interaction of services with the desktop using 'Interactive Services Detection'.

 

That means, if you are running PHP as a module of an Apache service, you won't be able to launch GUI apps using any method.  This kind of thing just won't work:

 

$WshShell = new COM("WScript.Shell");

$oExec = $WshShell->Run("notepad.exe", 7, false);

 

So, if you want to use Apache/PHP as a proxy for launching GUI apps, you'll need to run Apache as a console application. 

 

First, if Apache is already installed as a service, you'll need to set it's startup type to "manual" using the services snap-in.  (%SystemRoot%\system32\services.msc)  Search for Services in the start menu search box.

 

Then add a shortcut to C:\apache\bin\httpd.exe (or wherever Apache is installed) to your Startup folder, and set that shortcut to start minimized. You can use an app like TrayIt! to force Apache down into the system tray.

 

Then use any of the methods outlined on the PHP website and you will be able to open a Windows application from PHP and see it's GUI.

 

http://php.net/manual/en/book.exec.php

Link to comment
Share on other sites

I am running:

Linux MaD-pc 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux

 

And I am using this PHP:

Build Date May 2 2011 23:04:25

Server API Apache 2.0 Handler

Apache Version Apache/2.2.17 (Ubuntu)

 

I don't know if you need more details!

 

Well, the problem is that when I am trying to run a GUI program (a non-terminal-program) I get error messages:

cannot connect to the DISPLAY

cannot connect to :0.0

 

That's the problem.

Any other info needed?

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

Your Apache user (www on Ubuntu) will need to be in the groups with sufficient permissions to run desktop applications. I'm not exactly sure what groups this would entail on Ubuntu but on Gentoo, video should suffice.

 

Even then, I'm not sure how (or if) you could get permissions to execute something on another users desktop. You would likely need to have the process su to your own users first.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.