aspose file tools*
The moose likes Tomcat and the fly likes Compiled CGI on Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Compiled CGI on Tomcat" Watch "Compiled CGI on Tomcat" New topic
Author

Compiled CGI on Tomcat

Jason St Louis
Greenhorn

Joined: Jun 17, 2004
Posts: 6
Hi all.

Does anyone have any experience running CGI's on Tomcat (version 4.1.30 on Solaris 8)?

We are trying to run Tomcat standalone, but we are also running the mapquest connect cgi on our site. I am trying to use the org.apache.catalina.servlets.CGIServlet but it is dying on this cgi.

I wrote a simple "Hello World!" perl script that runs okay from the same spot, but the mapquest cgi fails with the following error:

2004-06-17 15:12:44 cgi: runCGI (stderr):Unrecognized character \177 at ${CATALINA_HOME}/webapps/mapquest/WEB-INF/cgi-bin/mqinterconnect line 1.

The biggest difference I can think of between the 2 cgi's is that one is a script and the other is compiled. Does this make any difference?

If I can't get this to work, we'll just have to run an apache httpd instance as well, but I want to avoid that right now if at all possible.

If you need any other configuration information, I can provide it.

Thanks.
[ June 17, 2004: Message edited by: Jason St Louis ]
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

It looks like you get that error when you try to run a compiled "C" cgi as if it was a perl script.

http://mail.python.org/pipermail/mailman-users/1999-January/000245.html

I'm thinking the cgiservlet only does perl. It probably invokes the perl interpreter through java.lang.Runtime and java.lang.Process .

One way to confirm is to check the source of org.apache.catalina.servlets.CGIServlet

You might be able to tell more (and perhaps skip the source) if you up the debug value.


I'm thiking perhaps Tomcat will grace you with more info in catalina.out (maybe even the string it send to the unix command line)
[ June 17, 2004: Message edited by: Mike Curwen ]
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

hmm... I did have better things to do tonight, but I'm avoiding them.


I've looked at the source, and it looks like there's an undocumented parameter? Maybe the version included in 4.1.30 is not the same as that available in HEAD..

but...

http://cvs.apache.org/viewcvs.cgi/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java?rev=1.24&only_with_tag=MAIN&view=markup

search on that page cgiExecutable
The first occurence sets it to "perl"
the second occurence sets it to whatever is passed in through the executable servlet init parameter.
and the third starts to build a command line, which is eventually passed to Runtime.getRuntime().exec()
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

one last one:

I don't know enough about CVS, so I'm might be completely wrong. But I checked the source code for the cgiservlet that was "tagged" as TOMCAT4-1-30. Does this mean that *THIS* is the version of cgiservlet that is in the tomcat 4.1.30 release? (Perhaps).

If so, the code that enables you to specify something other than 'perl' is *in* this version, but not documented.

fyi: it *IS* in the docs for Tomcat 5.x
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/cgi-howto.html (bottom of page)
Jason St Louis
Greenhorn

Joined: Jun 17, 2004
Posts: 6
So maybe if I'm running this on Solaris I can just pass a blank value to the executable init parameter since the cgi itself is executable.

I'll give it a try tommorrow and let you know how it turns out.

Thanks for the help.
Jason St Louis
Greenhorn

Joined: Jun 17, 2004
Posts: 6
It worked! Thanks again, Mike.
Jason St Louis
Greenhorn

Joined: Jun 17, 2004
Posts: 6
Just thought I'd make a note of this for anyone else who might be interested.

The test "Hello World!" perl script that I wrote continues to work after I changed the executable init paramater to blank. That doesn't suprise me since the script itself defines which interpreter to use (#!/usr/bin/perl).

So blanking out the executable parameter causes the CGIServlet to work with script CGI programs and compiled CGI programs (at least on Solaris).
[ June 18, 2004: Message edited by: Jason St Louis ]
 
Don't get me started about those stupid light bulbs.
 
subject: Compiled CGI on Tomcat
 
Similar Threads
404 Error
debug tomcat app under win xp
How to make a file executable as CGI process on Apache server ?
setting Tomcat 6 up to run CGI scripts (Perl)
Tomcat CGI to lunch Java Jar Server