Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Cannot launch simple applications (notepad, java) using Apache and PERL(CGI)

Reply
Thread Tools

Cannot launch simple applications (notepad, java) using Apache and PERL(CGI)

 
 
JDS
Guest
Posts: n/a
 
      05-24-2004
Hi:

Introduction:
-------------
I need to launch an Xwindows application and a java application from a
web-page running on Apache. The first is an exe file and the second is
a java file. I have a simple perl script to run these. These run fine
and the perl script launches the 2 applications (seperately), but I am
unable to get them to launch from an IE browser running on apache:
----------------------------
#!c:/perl/bin/perl.exe -w
use strict;
use CGI;

my $q = new CGI;
print $q->header( "text/plain" );
system "cmd.exe /c test.bat";
#system "xapp ";
----------------------------

test.bat is as follows:
-----test.bat-------
CALL notepad
REM CALL java -jar myapp.jar
--------------------

DETAILS:
--------
1. I can run on windows 2000 from the DOS prompt as follows:
*xwindows application (xapp.exe)
c:> xapp
*Java application.
c:> test.bat
This brings up the GUI for my java application.
2. The perl script above works and launches the applications in a
seperate window. However, it waits for the application to finish- does
not spawn a thread and forget about them.
QUESTION: How can I do that? e.g. the notepad application is launched
and control returns irrespective of what the user does in the
application. Currently, the DOS prompt freezes till the user exists
the application and retruns.

3. The above script does not run through the web-browser (IE running
apache). I had expected a seperate window to be launched for notepad,
or the xapp or the java application, but that does not happen.
QUESTION: I am lost. It looked like a simple problem and this must
have been experience before by folks. Would appreciate guidance
through this.

Thanks,

Jai.
 
Reply With Quote
 
 
 
 
Gregory Toomey
Guest
Posts: n/a
 
      05-24-2004
JDS wrote:

> Hi:
>
> Introduction:
> -------------
> I need to launch an Xwindows application and a java application from a
> web-page running on Apache.


You want to run programs from a browser? Browsers interpret HTML &
occasionally run Javascript. You may be able to do this from javascript.

gtoomey
 
Reply With Quote
 
 
 
 
Tim Hammerquist
Guest
Posts: n/a
 
      05-24-2004
Gregory Toomey <(E-Mail Removed)> wrote:
> JDS wrote:
> > I need to launch an Xwindows application and a java application from
> > a web-page running on Apache.

>
> You want to run programs from a browser? Browsers interpret HTML
> & occasionally run Javascript. You may be able to do this from
> javascript.


The CGI calls the programs on the server-side, but it looks like the OP
might be expecting both Apache and IE to be running on the same machine,
so JavaScript may well be a different but equally effective solution *in
this case*.

I'll not discuss how much the concept of a CGI and/or Javascript
application launching user apps offends my sense of program design, not
to mention security.

However, assuming the OP knows what he's doing (difficult as it is), he
may want to look at using the MS Windows "start" keyword in his system()
calls. I.e.:

system("start notepad.exe") && print "error launching notepad";

This will allow the notepad process to separate (vaguely similar to
"fork") from the CGI process.

There are myriad complications that this introduces, however. *IF*
Apache successfully executes this command and a notepad process does
indeed start, the notepad will run with the permissions of the Apache
service, not the logged-in user. I'm not sure what effect this could
have, and I have no intention of implementing this to find out.

This is an ugly and offensive hack which, if it works at all, will
instantly fail if the Apache server and browser run on separate
machines. There have been hundreds of posts of people attempting what
you post here and being shocked to find that no Notepad window appears
on the client machine, but the server's sysadmin finds a Notepad session
open on his desktop out of nowhere.

You have been warned, and Google will retain proof of warning
indefinitely.

HTH,
Tim Hammerquist
--
Two penguins were walking on an iceberg. The first penguin
said to the second, "you look like you are wearing a tuxedo."
The second penguin said, "I might be..."
--David Lynch, Twin Peaks
 
Reply With Quote
 
JDS
Guest
Posts: n/a
 
      05-24-2004
The applications that need to run are:
1. An X-windows application.
2. A Java Application.

Currently, I do understand the fact that the application that will
start will run on the server side. I also know that the java
application will need to be made into an applet and the X-windows
application will be also replaced by a web-based application. However,
I want to give a demo show what will eventually happen. In this case,
there is only one machine involved- the Apache server and the java
application and the x-windows application currently all run on the
same windows host.

What beats me is the fact that I cannot launch an application on the
same machine- I should be able to run the 4 lines of code to start a
notepad through the webserver. At this point, it is sufficient for my
demo purposes to be able to launch an application using Apache and
Perl as mentioned in my email.

Hope this explains the motivation.

Thanks,
Jai.


Johan Louwers <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>. ..
> What exactly do you want to do?
>
> The things you tell in your mail are running applications ... what
> kind of applications.... where is the application output send to?
>
>
> Regards,
> Johan Louwers.
>
>
> On 23 May 2004 20:51:20 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (JDS) wrote:
>
> >Hi:
> >
> >Introduction:
> >-------------
> >I need to launch an Xwindows application and a java application from a
> >web-page running on Apache. The first is an exe file and the second is
> >a java file. I have a simple perl script to run these. These run fine
> >and the perl script launches the 2 applications (seperately), but I am
> >unable to get them to launch from an IE browser running on apache:
> >----------------------------
> >#!c:/perl/bin/perl.exe -w
> >use strict;
> >use CGI;
> >
> >my $q = new CGI;
> >print $q->header( "text/plain" );
> >system "cmd.exe /c test.bat";
> >#system "xapp ";
> >----------------------------
> >
> >test.bat is as follows:
> >-----test.bat-------
> >CALL notepad
> >REM CALL java -jar myapp.jar
> >--------------------
> >
> >DETAILS:
> >--------
> >1. I can run on windows 2000 from the DOS prompt as follows:
> >*xwindows application (xapp.exe)
> >c:> xapp
> >*Java application.
> >c:> test.bat
> >This brings up the GUI for my java application.
> >2. The perl script above works and launches the applications in a
> >seperate window. However, it waits for the application to finish- does
> >not spawn a thread and forget about them.
> >QUESTION: How can I do that? e.g. the notepad application is launched
> >and control returns irrespective of what the user does in the
> >application. Currently, the DOS prompt freezes till the user exists
> >the application and retruns.
> >
> >3. The above script does not run through the web-browser (IE running
> >apache). I had expected a seperate window to be launched for notepad,
> >or the xapp or the java application, but that does not happen.
> >QUESTION: I am lost. It looked like a simple problem and this must
> >have been experience before by folks. Would appreciate guidance
> >through this.
> >
> >Thanks,
> >
> >Jai.

 
Reply With Quote
 
ForestHonerkamp ForestHonerkamp is offline
Junior Member
Join Date: Nov 2008
Posts: 1
 
      11-11-2008
I had this same problem, and wanted to be able to launch applications on the server machine using CGI and Apache (for a valid reason I assure you).

I was using the system() function call in my cgi, but notepad.exe was not showing up on my server's desktop.

(I am using Windows XP)
I went to Control Panel -> Administrative tools -> Services
Right click on Apache2.2 and select Properties.

Logon Tab.

Under the "Local System account" radio button , there is a "Allow service to interact with desktop" turn that on, and restart the service, and then the perl system() call will work correctly and notepad.exe will show up in the server desktop.

-----
(Sorry for resurrecting an old thread, but I hope this might help other Googlers discover the solution)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax Applications (75 links) : Sites/applications featuring/using Ajax. www.web20developers.com HTML 0 10-06-2006 03:28 AM
launch java(swing) applications from c/c++ on mac os x pratik.ganguly@gmail.com Java 1 03-22-2005 05:56 PM
AXIS jars org.apache.axis.wsi.* and org.apache.axis.transport.jms.* unkwb@web.de Java 0 02-23-2005 04:02 PM
Launch 2 applications sametime windows bigbinc Java 3 06-24-2004 11:00 AM
Cannot launch simple applications (notepad, java) using Apache and PERL(CGI) JDS Perl Misc 3 05-24-2004 06:33 PM



Advertisments