Re^2: System call within cgi script
by EvanK (Chaplain) on Jan 29, 2007 at 20:06 UTC
|
I suspect Joost is right. I just tested the portion of the OP's code calling notepad (with WampServer), and I now have a phantom notepad process that I can see from the task manager even though the notepad GUI never appears. Since system does a fork and waits for the command to complete, the perl script is waiting for notepad to exit and return a value. since noone ever closes notepad, it never completes, hence the permenant hang.
You could just fork and exec, but not only is that a sloppy solution, I assume you want the notepad window to actually display to the active user, right? Apache doesnt seem to want to allow that, and I have no idea how to get around it.
__________ The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
- Terry Pratchett
| [reply] |
|
|
| [reply] |
Re^2: System call within cgi script
by pmcaveman (Novice) on Jan 29, 2007 at 20:20 UTC
|
Well, the call I need to make isn't notepad, just an example to show that it isn't working. That, and everything is self-contained on one system -- it is for a documentation server for a large project.
Anyway, good to know about the :: operator. I wish I knew before I put the ' in a million places.
The error log says nothing. I do notice that I get an hourglass over the browser window I am trying to execute in. Is there any way to get any information as to what the heck is going on. | [reply] |
|
|
Well, if the program you're trying to call is an interactive program (which notepad from your example is and most GUI programs are), then your issue is that the called program starts and drops into a "wait for user input" loop. since its called from a CGI script, however, Apache seems to prevent said interactive program from displaying in the active windows session, so it will never get any user input.
diatolevi's suggestion of using Win32::Process is a step in the right direction, in that it starts the process and then exits the CGI script successfully. Unfortunately, it still does so under Apache, thus preventing the user from ever seeing the interactive program.
__________ The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
- Terry Pratchett
| [reply] |
|
|
Well, I finally got it. If I put my system call in a perl script, and call that from the .cgi script (closing STDOUT along the way), and then do the fork/exec dance, everything worked. Seems like the really long way to go to get where I needed to go, but whatever works. I will need to polish this turd up before I step in it again, but at least it is functional.
Thanks for the help!
-Kevin
| [reply] |
|
|
You should probably try again with a command-line only program. Unless you're running the server on the actual client that requests the page starting gui programs from a CGI is never going to do anything useful.
| [reply] |
|
|
Sorry, this is not a choice for me. I am migrating an old Apache/netscape system on a SUN computer, so these functions _used_ to work with apache, but apparently no longer (due to security enhancements, no doubt). The code is riddled with system calls, and I need to actually call firefox and pass in a local cgi script name with parameters.
It was really good to see the notepad task running with no gui. That is a good lead, at any rate. I was wondering why the system call would hang and not produce an answer. The task for notepad was owned by system -- would that make a difference?
The last change I did was to close(STDOUT) and close (STDIN) just vefore the system call. I recall seeing that in an FAQ somewhere around these parts... It didn't seem to have an effect though.
So, this is obviously an Apache/Perl problem. I have searched around for Apache help, and left some notes on http://groups.google.com/group/comp.infosystems.www.servers.ms-windows, but no answers/ideas yet.
BTW, is there an easy way to find a tree view of my threads?
| [reply] |