You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Linda Solomon <lk...@comcast.net> on 2006/01/20 00:14:26 UTC

Re: tomcat 5 and cgi execution - simple fix

Hello,

I don't believe that Tomcat 4 executed every cgi thru "perl".
If I execute
"perl cgi-program"

from the Linux command line, I get the same error that occurs when
Tomcat 5 executes a cgi using its default "executable" (that is, perl).
So, the problem is that perl cannot handle anything but scripts.

Through other means, I found that the Linux program /bin/doexec
executes all of the cgi's as needed.
I set the "executable" to "/bin/doexec" and all is well once again.

I know this solution works on a Linux platform (both Redhat 7.3 and 
Redhat AS3.0).
I do not know what solution works for other platforms.

Thanks,

Linda

Linda Solomon wrote:

> Mark,
>
> Thanks for the suggestion.
> I read thru the differences and nothing specific stood out as the root 
> of my problem.
> I noticed that hash tables are replaced by array lists;
> a new option is available to indicate if the shell environment should 
> be passed (or not) --
> I think I need to set that;
> the release notes indicate that a patch was made to prevent deadlock 
> between stderr and
> large stdout data .
>
> This patch solves this problem by having a single loop which
> reads stderr if it's ready, or stdout if ready.
> Fixes Bug 12041
>
>
> My web-application is a combination of html, javascript, perl scripts, 
> c++ programs, and java applets.
> My project is working rewriting this web-application as a J2EE  
> application.
> However, we still need to use the older web-application for some time..
>
> So, using the default executable in the cgi definition for 
> tomcat/conf/web.xml ,
> the perl scripts work fine.
> When I execute any of the c++ programs, I get a white (that is, blank, 
> empty)
> browser window in return.
> When I look at the tomcat 5.0  logs, the findCGI and runCGI seem to
> determine the cgi name, path and parameters correctly.
> However, I see a message that states runCGI received "\x7F" on stderr .
> I am guessing that perl attempted to read the c++ executable as a file 
> (so that it could interpret it)
> because the first byte of every c++ program is "\x7F"  (that is, 
> accounting for  little-endian, since
> the system is running on a Dell 1750 running Redhat AS 3.0.)
>
> I can fake out the system by creating a cshell-script with the same 
> name as the c++ executable
> and statically call the c++ cgi from within the cshell-script. The 
> cshell-script is executed successfully, the
> cshell-script executes the c++ cgi executable successfully and my 
> expected output comes back
> to the browser window.
>
> Any suggestions?
>
> Linda
>
> Mark Thomas wrote:
>
>> Linda Solomon wrote:
>>  
>>
>>> I followed the instructions for configuring tomcat 5 for cgi.
>>> However, tomcat 5 contains a new xml variable:
>>> executable - The of the executable to be used to run the script. 
>>> Default
>>> is perl.
>>>
>>> Using the default allows the perl cgis to work fine, but the c++ cgi's
>>> do not work.
>>>   
>>
>> This is unlikely to be a factor. Before it was configurable it was
>> hard-coded to perl so if you leave it as the default there should be
>> no functional change.
>>
>> There are, however, a whole stack of other changes that may be a
>> factor. The following (rather long) URL should show you the changes.
>> http://svn.apache.org/viewcvs.cgi/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java?p1=tomcat%2Fcontainer%2Fcatalina%2Ftrunk%2Fcatalina%2Fsrc%2Fshare%2Forg%2Fapache%2Fcatalina%2Fservlets%2FCGIServlet.java&rev=366305&r1=302487&r2=366305&diff_format=h 
>>
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>  
>>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat 5 and cgi execution - simple fix

Posted by Mark Thomas <ma...@apache.org>.
Linda Solomon wrote:
> Hello,
> 
> I don't believe that Tomcat 4 executed every cgi thru "perl".
> If I execute
> "perl cgi-program"
Found it. Didn't quite go back far enough in the change logs. The
cause is the fix for bug 22858.
(http://issues.apache.org/bugzilla/show_bug.cgi?id=22858)

> I set the "executable" to "/bin/doexec" and all is well once again.
> I know this solution works on a Linux platform (both Redhat 7.3 and
> Redhat AS3.0).
> I do not know what solution works for other platforms.
I haven't tested this but it should work. Define the CGI servlet
several times in web.xml (you will need to specify a different
servlet-name for each instance) and provide different mapping and init
parameters for each combination you need to support. For example you
could define an extension mapping of *.pl with an executable of "perl"
and *.cgi with an executable of "/bin/sh" or whatever is appropriate
for your various cgi scripts. Be aware that if you use extension
mapping you must set cgiPathPrefix to "". Also bear in mind the
mapping rules in  SRV.11.1 for mapping requests to servlets.

HTH,

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org