Executing External Application
9 answers - 453 bytes -

I am trying use PHP to run an application on Windows XP Pro machine. The
application runs from the command line however, when I try to run it
through Apache (I've tried called the script through a browser and a
SAP service) the application will not run. I have tried the exec,
shell_exec and system commands.
How can I get my Application to execute when it is called through Apache?
example code:
system("notepad.exe");
No.1 | | 184 bytes |
| 
You should only run console applications, not gui apps Also, by default
Apache is installed as a system service, and in that case it doesn't make
sense to run graphical apps
No.2 | | 787 bytes |
| 
Brian Stakes wrote:
I am trying use PHP to run an application on Windows XP Pro machine. The
application runs from the command line however, when I try to run it
through Apache (I've tried called the script through a browser and a
SAP service) the application will not run. I have tried the exec,
shell_exec and system commands.
How can I get my Application to execute when it is called through Apache?
--
example code:
system("notepad.exe");
You may have the same problem I did when trying to use Winzip. You need
to tell Windows to allow the service to interact with the desktop.
Run - services.msc. Right click on your Apache service - select
Properties and then the Log on tab. Check - Allow service to interact
with desktop
No.3 | | 1163 bytes |
| 
Chuck Anderson wrote:
Brian Stakes wrote:
>I am trying use PHP to run an application on Windows XP Pro machine. The
>application runs from the command line however, when I try to run it
>through Apache (I've tried called the script through a browser and a
>SAP service) the application will not run. I have tried the exec,
>shell_exec and system commands.
>>
>How can I get my Application to execute when it is called through Apache?
>>
>>
>example code:
>system("notepad.exe");
>
You may have the same problem I did when trying to use Winzip. You need
to tell Windows to allow the service to interact with the desktop.
Run - services.msc. Right click on your Apache service - select
Properties and then the Log on tab. Check - Allow service to interact
with desktop
Eww!! Eww!! and thrice EWW!! There is *never*, and I mean *never* an
acceptable reason to run a GUI app in response to a web request - even
on an Intranet.
*NEVER!!!!*
IMMH
-Stut
No.4 | | 1631 bytes |
| 
Please include the list when replying.
hairtwoday (AT) gmail (DOT) com wrote:
Stut wrote:
>Eww!! Eww!! and thrice EWW!! There is *never*, and I mean *never*
>an acceptable reason to run a GUI app in response to a web request
>- even on an Intranet.
>
>*NEVER!!!!*
>
>IMMH
>
Bah. Pure ignorance. Here's one reason. I run Apache on my PC. I
wrote a Php script that I run as a scheduled task to zip up a folder
once a day. I used the WinZip command line interface. It will not
run until I allow Apache to interact with the desktop. Simple, to
the point, and it works.
WinZip is a GUI app. There are lots of CLI utilities for zipping - use
one of those! If you're doing this as a personal utility, why is Apache
getting involved in running a PHP script as a scheduled task?
Here's another. I have a photo gallery script written in Php that
triggers an Irfanview slide show. It's very efficient and simple.
Never come across Irfanview, but a quick Google reveals a GUI app for
viewing images. How is this useful for a web-based visitor?
You're Eww, Eww, Eww and Never!! rules are just so much hot air.
Maybe in your opinion, which you are entitled to just as much as I am.
However, IMH web-based appplications and GUI applications should not
mix. Ever. But that's just my opinion. If your use is not as a web
application, but rather as a way to start processes on your local
machine I would question why Apache needs to be involved at all.
-Stut
No.5 | | 3611 bytes |
| 
Stut wrote:
Please include the list when replying.
hairtwoday (AT) gmail (DOT) com wrote:
>Stut wrote:
>
Eww!! Eww!! and thrice EWW!! There is *never*, and I mean *never*
an acceptable reason to run a GUI app in response to a web request
- even on an Intranet.
*NEVER!!!!*
IMMH
>Bah. Pure ignorance. Here's one reason. I run Apache on my PC. I
>wrote a Php script that I run as a scheduled task to zip up a folder
>once a day. I used the WinZip command line interface. It will not
>run until I allow Apache to interact with the desktop. Simple, to
>the point, and it works.
>
>
WinZip is a GUI app. There are lots of CLI utilities for zipping - use
one of those! If you're doing this as a personal utility, why is Apache
getting involved in running a PHP script as a scheduled task?
Good point. I guess I needed to do that while I was testing the script
through my browser. WinZip would not run if I did not let Apache (Php
module) interact with the desktop. My cron job (errr I mean
scheduled task) does run Php via the command line.
And I actually have switched to using 7-zip now, as it does not require
interaction with the desktop. At the time I built this personal
utility, though, Winzip was all I had to work with and it got the job
done in a timely manner.
I see no point in questioning why someone wants to invoke notepad from a
web page. It could be a personal utility like some of the ones I write
for myself.
>Here's another. I have a photo gallery script written in Php that
>triggers an Irfanview slide show. It's very efficient and simple.
>
>
Never come across Irfanview, but a quick Google reveals a GUI app for
viewing images. How is this useful for a web-based visitor?
This runs on my PC. I have a set of Php scripts that produce HTML photo
galleries from folders full of photos and it requires user (my)
interaction. option I have is to create a text file of all the
photo image file paths and then invoke Irfanview with that file to start
a full screen slide show.
>You're Eww, Eww, Eww and Never!! rules are just so much hot air.
>
>
Maybe in your opinion, which you are entitled to just as much as I am.
However, IMH web-based appplications and GUI applications should not
mix. Ever.
I see no problem with the implementation I used. It is the easiest and
most efficient way to view a slideshow of the source images I am going
to include (or have included) in an HTML photo gallery. Irfanview is
very simple to use. It reduces all large files to the size of the
desktop and runs a completely full screen slideshow without any further
effort on my part. It does require, however, that Apache (Php module)
be able to interact with the desktop.
But that's just my opinion. If your use is not as a web
application, but rather as a way to start processes on your local
machine I would question why Apache needs to be involved at all.
The browser/server interface is the easiest way for me to to create a
GUI on my PC - especially since I already have Apache and Php
installed. I could resurrect my old skills in C and C compliers
(makefiles), then tackle the Windows API (ugh), but why bother when I
have these tools available and the knowledge to use them right now.
No.6 | | 1160 bytes |
| 
I checked the button which should allow apache to interact with the
desktop, but to no avail. Was there anything else that you had to do in
order to get apache to interact with an Application?
Chuck Anderson wrote:
Brian Stakes wrote:
>I am trying use PHP to run an application on Windows XP Pro machine. The
>application runs from the command line however, when I try to run it
>through Apache (I've tried called the script through a browser and a
>SAP service) the application will not run. I have tried the exec,
>shell_exec and system commands.
>>
>How can I get my Application to execute when it is called through Apache?
>>
>>
>example code:
>system("notepad.exe");
>
You may have the same problem I did when trying to use Winzip. You need
to tell Windows to allow the service to interact with the desktop.
Run - services.msc. Right click on your Apache service - select
Properties and then the Log on tab. Check - Allow service to interact
with desktop
No.7 | | 1206 bytes |
| 
Brian Stakes wrote:
I checked the button which should allow apache to interact with the
desktop, but to no avail. Was there anything else that you had to do in
order to get apache to interact with an Application?
Chuck Anderson wrote:
>Brian Stakes wrote:
>
I am trying use PHP to run an application on Windows XP Pro machine. The
application runs from the command line however, when I try to run it
through Apache (I've tried called the script through a browser and a
SAP service) the application will not run. I have tried the exec,
shell_exec and system commands.
How can I get my Application to execute when it is called through Apache?
example code:
system("notepad.exe");
>You may have the same problem I did when trying to use Winzip. You need
>to tell Windows to allow the service to interact with the desktop.
>>
>Run - services.msc. Right click on your Apache service - select
>Properties and then the Log on tab. Check - Allow service to interact
>with desktop
Nothing else I can think of.
No.8 | | 600 bytes |
| 
I read in the CHM manual that phplib functions are included with PHP after version 4. However my PHP5 interpreter bails when it encounters the commands
$iterator=$chapter_array->getIterator();
echo $iterator->current();
I'm assuming these phplib functions die because they are not found or installed. Can anyone tell me what I need to include or enable to turn phplib functions on in php5? Do I need to download and install the phplib distro from sourceforge and follow their instructions for installing phplib?
Bill Angus, MA
http://www.psychtest.com
No.9 | | 322 bytes |
| 
I can give you an example when you NEED to run GUI app from PHP. I run a game server...its on the same box as the apache webserver. Ive created a php page where my administrators for the game server have ability to restart/stop the game server. Meaning that PHP will launch an external EXE program...it has GUI.