You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rahul R <ra...@gmail.com> on 2014/06/20 13:49:24 UTC

CGI script to work on Tomcat

Hi

 I am trying to migrate something which was working under apache to tomcat.
I had an html form which takes user input values and pass those values and
executes some cgi scripts. But when I moved html and cgi under tomcat, the
html form is loading properly, but when I click submit, its giving 404
error for the cgi execution.

I have my html files under ROOT and cgi scripts under ROOT/WEB-INF/cgi
Tomcat Version: 7.0.54

And in my html form I have mentioned the cgi location as
<action='./WEB-INF/cgi/read_toggle.cgi'>

I followed the steps mentioned in the below url.

http://www.wellho.net/solutions/java-running-cgi-scripts-in-apache-tomcat.html

I don't see anything in the catalina.out or any other logs. Kindly me help
to fix this issue.


-- 
Thanks,
Regards,
Rahul R

  .~.
  /V\
 // \\
/(   )\
 ^`~'^

Mob: 09008030921

Re: CGI script to work on Tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 6/21/14, 9:46 AM, André Warnier wrote:
> Christopher Schultz wrote:
>> The OP. Look up in the configuration: the "executable" is set to 
>> "perl".
> 
> That's just the default, as it comes in the standard Tomcat 
> distribution. See also 
> https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html#Configuration
>
>  The OP never actually said what the script was. Which is a reason
> why I raised the question.

Fair enough.

> He could also be using a stand-alone Java application as a cgi-bin 
> script, for all we know.. Wouldn't that be interesting ?  Would the
> JVM which runs Tomcat actually be smart enough to notice this, and
> not load and run another JVM then ?

No, nor should it. If you wanted to launch another JVM for stability's
sake (e.g. your "standalone" Java program was buggy as heck and might
run out of memory, etc.) then you certainly wouldn't want the JVM to
outsmart you and do something other than what you've asked.

As an aside, I've recently done some hacking on Runtime.exec in a
litte utility program I've written in Java to get the benefit of the
JDBC API (it's a CLI interactive SQL script runner). I wanted to
launch $EDITOR and let the user edit a query in the query buffer, but
launching something like vi from Java is evidently not possible: Java
doesn't have access to the console... only stdin, stdout, and stderr.
I tried writing pumped-streams to just fake it, but basically nothing
works. :(

>>> (not saying that it isn't, but nobody said it was either). As
>>> it stands, whatever it is, it is being run (at first) by perl.
>>> But if perl notice another interpreter in the shebang line, it
>>> will happily cede its turn.
>> 
>> Fair enough. I've seen some stupid things in my time, but having
>> Perl hand-off to some other binary just seems wasteful.
> 
> It is.  Tomcat runs the CGI servlet (actually, a Java JVM does
> that); the CGI servlet sets up a complete CGI environment
> (variables and all), then asks the JVM to load and run a perl
> interpreter (and the JVM probably asks the underlying OS to do
> that).  The perl interpreter loads, reads the cgi script, sees the
> shebang line, and exec's a shell to run the script.  Then the shell
> reads and runs the script.  And the same at each invocation. If one
> is looking for a small footprint and/or performance, that's not 
> exactly the way to go.

Any sane OS, though, would preserve the environment of the process
through those various exec() calls without modification. So going from
Java -> native causes a bit of a stir, but after that, it's fairly
well optimized.

> I was basically raising the question, because it seems to me that,
> if the OP actually read the page 
> https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html, it
> nevertheless does not seem that he read it very carefully.

That's pretty clear, given the questions being asked. The page is like
500 words long. It's not like the information is /buried/ in there or
anything. If that page suffers from any problem, it's likely to be
that the information density is too /high/.

> So the fact that perl is the default executable may have escaped
> his attention. And since perl will call a shell to run the script
> if this actually is a shell script with a proper shebang line, he
> may never notice all the above. And then wonder why this appears
> so resource-intensive.
> 
>> 
>>> Anyway, it raises the fundamental question of why go though
>>> all the trouble to run a (possibly perl) cgi-bin script within
>>> Tomcat ?
>> 
>> +1
>> 
> 
> (Also @David) :
> 
> Let's face it : Tomcat is not particularly optimised to run
> cgi-bin scripts, be they perl or otherwise.  There are better tools
> to do this, such as an Apache httpd front-end which the OP seems to
> have been using so far.
> 
> In this particular case, I believe it would probably be better to
> keep the configuration maybe a bit more complex, but probably more
> efficient. There are cases where simpler is not necessarily better,
> and I felt that it was worthwhile pointing this out.

+1

mod_perl is the right answer to this problem. This is one of many
cases where fronting Tomcat with a web server is an appropriate thing
to do.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTqDjeAAoJEBzwKT+lPKRYciEP+wRFd1v3ph1MV7WEZrTTvWKz
XUmhf3QBaJbrAYwaFCJxjJT0LNKKYl8nHM6+kjgjbHsjl30h/0ee9/1Rfbg6SfQO
WHO6cDn1Gu05pmSASMQ9uc8hdUUdL+fpJWhCrUsTUztvON+hRvSJzGY7fYEPFc//
C/P7z5fcdP77ToI80vO7GGB/LXMOtFZHLaliT2ISqqwz0kum2E9VS3c+4rXAOBZs
ZpGwzMlc/rIvx8V5hJE5b4/j53BgsskizMQvLWMY1UJGCS0pPxnHtOLvaUlUwf/g
MHWlIeMIAMEJbyy+wYxE5MMjRu/mtzmEnYfjJtx3C0hHkJqWZwQsSq4Te5+2o9tc
HDmstreWwWRFr1eM5KIKJ8iy+fGM9m/rIGQw42xKylD5L/L5vpDR3KnoNrSluWwI
0/clC3UIrUp+2rgG9Kz+bEFtpdh3qYvi8clFpgbje8BWJo7igHBMWLenEwG22xIS
h90XV9c+T+ZB0r8OYYbqmyOUiM858z8NjoFEq94oCih3t+4oUbSCHQRYCNPFiMWU
mecjWfDMcHh5jUrvmi851uRihGbCKzODo/a7SR7+lRhFX4rlHsXu0AdGjHgZDENC
7IyxUdJpWKeEW32PaBMPMfJR9b/b5dXVGteEWiBcS69nYf+E4LogLoo0y+OVzhGg
9EjHvi//Ng/OLeXEQ+tB
=hvyd
-----END PGP SIGNATURE-----

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


Re: CGI script to work on Tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> André,
> 
> On 6/20/14, 6:19 PM, André Warnier wrote:
>> Christopher Schultz wrote:
>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
>>>
>>> Rahul,
>>>
>>> On 6/20/14, 3:10 PM, Rahul R wrote:
>>>> This is from my conf/web.xml
>>>>
>>>> <servlet> <servlet-name>cgi</servlet-name>
>>>>
>>>> <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
>>>>
>>>>
> <init-param>
>>>> <param-name>debug</param-name> <param-value>0</param-value> 
>>>> </init-param> <init-param>
>>>> <param-name>cgiPathPrefix</param-name> 
>>>> <param-value>WEB-INF/cgi</param-value> </init-param>
>>>> <init-param> <param-name>passShellEnvironment</param-name> 
>>>> <param-value>true</param-value> </init-param> <init-param> 
>>>> <param-name>executable</param-name>
>>>> <param-value>perl</param-value> </init-param>
>>>>
>>>> <load-on-startup>5</load-on-startup> </servlet>
>>>>
>>>>
>>>> <servlet-mapping> <servlet-name>cgi</servlet-name> 
>>>> <url-pattern>/cgi-bin/*</url-pattern> </servlet-mapping>
>>>>
>>>>
>>>> Please let me know what do you mean by privileged usage.
>>> https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html
>>>
>>> Since you have mapped the CGIServlet to /cgi-bin, then you will
>>> want to have your HTML file (located in the webapp root) to
>>> reference "/cgi-bin/read_toggle.cgi" as the action.
>>>
>>> Note that the URL reference is mapped from the URL space 
>>> (/cgi-bin/read_toggle.cgi) into the webapp's resource space 
>>> (WEB-INF/cgi/read_toggle.cgi) which is why the paths don't appear
>>> to match.
>>>
>>> Finally, if the Perl script isn't that complicated, you should 
>>> consider re-writing it in Java since you are using a Java
>>> application server. It will be much easier to deal with
>>> everything that way.
>>>
>> Who said that the cgi-bin script was perl ?
> 
> The OP. Look up in the configuration: the "executable" is set to
> "perl". 

That's just the default, as it comes in the standard Tomcat distribution. See also 
https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html#Configuration

The OP never actually said what the script was.
Which is a reason why I raised the question.

(perl may not even be installed on that system; but since so far Tomcat did not even 
trigger the CGI servlet, we are not yet at the point where this would show up.)

I suppose he could be using a tcl/tk binary re-named to "perl"
> just to have a laugh, but probably not.

He could also be using a stand-alone Java application as a cgi-bin script, for all we know..
Wouldn't that be interesting ?  Would the JVM which runs Tomcat actually be smart enough 
to notice this, and not load and run another JVM then ?

> 
>> (not saying that it isn't, but nobody said it was either). As it
>> stands, whatever it is, it is being run (at first) by perl. But if 
>> perl notice another interpreter in the shebang line, it will
>> happily cede its turn.
> 
> Fair enough. I've seen some stupid things in my time, but having Perl
> hand-off to some other binary just seems wasteful.

It is.  Tomcat runs the CGI servlet (actually, a Java JVM does that); the CGI servlet sets 
up a complete CGI environment (variables and all), then asks the JVM to load and run a 
perl interpreter (and the JVM probably asks the underlying OS to do that).  The perl 
interpreter loads, reads the cgi script, sees the shebang line, and exec's a shell to run 
the script.  Then the shell reads and runs the script.  And the same at each invocation.
If one is looking for a small footprint and/or performance, that's not exactly the way to go.

I was basically raising the question, because it seems to me that, if the OP actually read 
the page https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html, it nevertheless does not 
seem that he read it very carefully.  So the fact that perl is the default executable may 
have escaped his attention.  And since perl will call a shell to run the script if this 
actually is a shell script with a proper shebang line, he may never notice all the above.
And then wonder why this appears so resource-intensive.

> 
>> Anyway, it raises the fundamental question of why go though all
>> the trouble to run a (possibly perl) cgi-bin script within Tomcat
>> ?
> 
> +1
> 

(Also @David) :

Let's face it : Tomcat is not particularly optimised to run cgi-bin scripts, be they perl 
or otherwise.  There are better tools to do this, such as an Apache httpd front-end which 
the OP seems to have been using so far.
In this particular case, I believe it would probably be better to keep the configuration 
maybe a bit more complex, but probably more efficient.
There are cases where simpler is not necessarily better, and I felt that it was worthwhile 
pointing this out.



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


Re: CGI script to work on Tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 6/20/14, 6:19 PM, André Warnier wrote:
> Christopher Schultz wrote:
>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
>> 
>> Rahul,
>> 
>> On 6/20/14, 3:10 PM, Rahul R wrote:
>>> This is from my conf/web.xml
>>> 
>>> <servlet> <servlet-name>cgi</servlet-name>
>>> 
>>> <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
>>>
>>>
>>
>>> 
<init-param>
>>> <param-name>debug</param-name> <param-value>0</param-value> 
>>> </init-param> <init-param>
>>> <param-name>cgiPathPrefix</param-name> 
>>> <param-value>WEB-INF/cgi</param-value> </init-param>
>>> <init-param> <param-name>passShellEnvironment</param-name> 
>>> <param-value>true</param-value> </init-param> <init-param> 
>>> <param-name>executable</param-name>
>>> <param-value>perl</param-value> </init-param>
>>> 
>>> <load-on-startup>5</load-on-startup> </servlet>
>>> 
>>> 
>>> <servlet-mapping> <servlet-name>cgi</servlet-name> 
>>> <url-pattern>/cgi-bin/*</url-pattern> </servlet-mapping>
>>> 
>>> 
>>> Please let me know what do you mean by privileged usage.
>> 
>> https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html
>> 
>> Since you have mapped the CGIServlet to /cgi-bin, then you will
>> want to have your HTML file (located in the webapp root) to
>> reference "/cgi-bin/read_toggle.cgi" as the action.
>> 
>> Note that the URL reference is mapped from the URL space 
>> (/cgi-bin/read_toggle.cgi) into the webapp's resource space 
>> (WEB-INF/cgi/read_toggle.cgi) which is why the paths don't appear
>> to match.
>> 
>> Finally, if the Perl script isn't that complicated, you should 
>> consider re-writing it in Java since you are using a Java
>> application server. It will be much easier to deal with
>> everything that way.
>> 
> 
> Who said that the cgi-bin script was perl ?

The OP. Look up in the configuration: the "executable" is set to
"perl". I suppose he could be using a tcl/tk binary re-named to "perl"
just to have a laugh, but probably not.

> (not saying that it isn't, but nobody said it was either). As it
> stands, whatever it is, it is being run (at first) by perl. But if 
> perl notice another interpreter in the shebang line, it will
> happily cede its turn.

Fair enough. I've seen some stupid things in my time, but having Perl
hand-off to some other binary just seems wasteful.

> Anyway, it raises the fundamental question of why go though all
> the trouble to run a (possibly perl) cgi-bin script within Tomcat
> ?

+1

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTpOz4AAoJEBzwKT+lPKRY7HUP/0ifaL1kLQA7Ey4nVjIGRfMJ
DP5JBkTpoampQIJbqnf8DwNZmm6chRPK75RK5nioPghac3uXUuL6UgW6BCrfccBa
tcprd7jK5dwQPi0vNsgTDaypPtIw30mt1z3TieHJ2qFlBPU+Fa4SGl8KHGi/GsXA
Ti7yt+2wz1a1BkWrd1u39qZeC/x0bHkPr4pd7OONLpaxiqWMoTnzpasPFQMu3lt2
Rjqt4PhMy3khu5UirW0CUb/sMR8d74sflZ80bhf/xe2id3UiEsMWiIU9HrG3s37K
bN1NtUFODFKbM2v7ZD6ZXkndqYMXfTp8cyopOjwZB3XkDF+tN9DHyCf+wCLFYBgj
VMkkv+XPssy1RMOaifQdhLsrdd8TwMfqUWC+QTiuEYgmQ8CoRzm5j7oQKZE3WfjX
8xj0xEmcCwhfXOYo/zeXuqBniMyQPFqhB5y7rj9ChTBGXjm1GsWDTTj4YSRjx/As
DVqVcn/G/ZvB6MllcXu7xGHLul36SnP5pJs2DpMzqnmUoHCkTnnPaYqv81TMKWGj
CF63o+kUrhKZBYG8FY5nSe/8uBg9Rkg6iCXu+nfUCFe7LgoFIcz5R7WsyJ4kOF1Q
4JgwdlMoRFh2pYi6egyQT0kDKXc6yUTF/q0chTxCNsW+YA3sPpBetpQTnOtsTI1O
Wl9WfLRZsYTZD9Mg3LjP
=8uKG
-----END PGP SIGNATURE-----

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


Re: CGI script to work on Tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

David,

On 6/20/14, 7:59 PM, David Kerber wrote:
> On 6/20/2014 6:19 PM, André Warnier wrote:
> 
> ...
> 
>>> Finally, if the Perl script isn't that complicated, you should 
>>> consider re-writing it in Java since you are using a Java
>>> application server. It will be much easier to deal with
>>> everything that way.
>>> 
>> 
>> Who said that the cgi-bin script was perl ? (not saying that it
>> isn't, but nobody said it was either). As it stands, whatever it
>> is, it is being run (at first) by perl. But if perl notice
>> another interpreter in the shebang line, it will happily cede its
>> turn.
>> 
>> Anyway, it raises the fundamental question of why go though all
>> the trouble to run a (possibly perl) cgi-bin script within Tomcat
>> ?
> 
> It sounds like the OP is trying to eliminate a layer (HTTPD) in
> his application without rewriting his scripts.  Seems like a
> reasonable goal to me.

Yeah, but doing CGI in httpd is dead simple. Doing in through Tomcat
is a pain in the neck. IMO any reasonable production application needs
to have at least 2 back-end application servers, so you need a proxy
no matter what. I suppose you could use a hw lb, but those things know
how to route stuff like CGI to some other server, too.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTpO1GAAoJEBzwKT+lPKRYrdQP/1c/SuiTF6o2HkgQh0CuH6TK
ndC0YjtSR2Gtmo2Ry7ynDjjPDfcNLcElv+n1Rpl/TWUFHLGJ4r3uvuSZ/ly91zXD
7/xvknjB+/l9yf+EYyJxx4XjV9O+q77Ae5V43pw+b4XzzK95NQ7x/ZS8A5dUW1yr
4mI8pc3ytgEVIOrQV93j+pCgDPTZWpJkZULqLB3QMm+XJwNmdytscSmjzte594qQ
TXNgGx6x+obSK6cPaVtAx5q9VfffpGMSS45869ZLBiT7CwubSBsSaBAFZWsYkg3p
HIxwmRt3on/rSSrtfYm0OlaECFwAOXd9nT5Oq6BE4VQUCSxp4Ao0nNYtOz+rU0Tz
km7CIAmsQwRTEeL9p8CYUJql/10vd35C4gghCGqYYCnJ/vDPvV/sdQwUaDjjJIbD
QOKrOGLPF5Clgf+1nx51urer/WtloWt7cb9/LWZjrVyNFGjvoOlCKzGXCSz5/q0N
KISYEFw3y9twyWLwz52vX+gmaThoKeMFwlH7HcCWQDp98zlLuXaaknIQHdGe9oW4
HEOUvRSPCVn9q0Dy4UB7wnkND8eYmkG3We9Rmbi9TVIxtxI8GEiQLFidnJqr1WWW
0XKP0xr9SE6KkFswSG/iFAK1ZfST+DbFksMl/IO6C/7WWzwbLnjC4PYkRl+SB6fG
sSnMUItaMZ40cdPRYEj+
=LOMA
-----END PGP SIGNATURE-----

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


Re: CGI script to work on Tomcat

Posted by David Kerber <dc...@verizon.net>.
On 6/20/2014 6:19 PM, André Warnier wrote:

...

>> Finally, if the Perl script isn't that complicated, you should
>> consider re-writing it in Java since you are using a Java application
>> server. It will be much easier to deal with everything that way.
>>
>
> Who said that the cgi-bin script was perl ? (not saying that it isn't,
> but nobody said it was either).
> As it stands, whatever it is, it is being run (at first) by perl. But if
> perl notice another interpreter in the shebang line, it will happily
> cede its turn.
>
> Anyway, it raises the fundamental question of why go though all the
> trouble to run a (possibly perl) cgi-bin script within Tomcat ?

It sounds like the OP is trying to eliminate a layer (HTTPD) in his 
application without rewriting his scripts.  Seems like a reasonable goal 
to me.



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


Re: CGI script to work on Tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Rahul,
> 
> On 6/20/14, 3:10 PM, Rahul R wrote:
>> This is from my conf/web.xml
>>
>> <servlet> <servlet-name>cgi</servlet-name>
>>
>> <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
>>
>>
> <init-param>
>> <param-name>debug</param-name> <param-value>0</param-value> 
>> </init-param> <init-param> <param-name>cgiPathPrefix</param-name> 
>> <param-value>WEB-INF/cgi</param-value> </init-param> <init-param> 
>> <param-name>passShellEnvironment</param-name> 
>> <param-value>true</param-value> </init-param> <init-param> 
>> <param-name>executable</param-name> 
>> <param-value>perl</param-value> </init-param>
>>
>> <load-on-startup>5</load-on-startup> </servlet>
>>
>>
>> <servlet-mapping> <servlet-name>cgi</servlet-name> 
>> <url-pattern>/cgi-bin/*</url-pattern> </servlet-mapping>
>>
>>
>> Please let me know what do you mean by privileged usage.
> 
> https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html
> 
> Since you have mapped the CGIServlet to /cgi-bin, then you will want
> to have your HTML file (located in the webapp root) to reference
> "/cgi-bin/read_toggle.cgi" as the action.
> 
> Note that the URL reference is mapped from the URL space
> (/cgi-bin/read_toggle.cgi) into the webapp's resource space
> (WEB-INF/cgi/read_toggle.cgi) which is why the paths don't appear to
> match.
> 
> Finally, if the Perl script isn't that complicated, you should
> consider re-writing it in Java since you are using a Java application
> server. It will be much easier to deal with everything that way.
> 

Who said that the cgi-bin script was perl ? (not saying that it isn't, but nobody said it 
was either).
As it stands, whatever it is, it is being run (at first) by perl. But if perl notice 
another interpreter in the shebang line, it will happily cede its turn.

Anyway, it raises the fundamental question of why go though all the trouble to run a 
(possibly perl) cgi-bin script within Tomcat ?

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


Re: CGI script to work on Tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Rahul,

On 6/20/14, 3:10 PM, Rahul R wrote:
> This is from my conf/web.xml
> 
> <servlet> <servlet-name>cgi</servlet-name>
> 
> <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
>
> 
<init-param>
> <param-name>debug</param-name> <param-value>0</param-value> 
> </init-param> <init-param> <param-name>cgiPathPrefix</param-name> 
> <param-value>WEB-INF/cgi</param-value> </init-param> <init-param> 
> <param-name>passShellEnvironment</param-name> 
> <param-value>true</param-value> </init-param> <init-param> 
> <param-name>executable</param-name> 
> <param-value>perl</param-value> </init-param>
> 
> <load-on-startup>5</load-on-startup> </servlet>
> 
> 
> <servlet-mapping> <servlet-name>cgi</servlet-name> 
> <url-pattern>/cgi-bin/*</url-pattern> </servlet-mapping>
> 
> 
> Please let me know what do you mean by privileged usage.

https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html

Since you have mapped the CGIServlet to /cgi-bin, then you will want
to have your HTML file (located in the webapp root) to reference
"/cgi-bin/read_toggle.cgi" as the action.

Note that the URL reference is mapped from the URL space
(/cgi-bin/read_toggle.cgi) into the webapp's resource space
(WEB-INF/cgi/read_toggle.cgi) which is why the paths don't appear to
match.

Finally, if the Perl script isn't that complicated, you should
consider re-writing it in Java since you are using a Java application
server. It will be much easier to deal with everything that way.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTpJ6zAAoJEBzwKT+lPKRYJHUP/0rhRGpRp0K+0wvDclh8zqlJ
QeX6sFeBtjroCtL716+BCdMW/hKnkPcQDElDvv5Rsh9A9CiRaC3iylUBhhk/wrZk
fjk3jeIKn5ZbiZXYBr4tg3Ut1hE/JjRwyCYduol68GPxRmucdCGmkSqacTZJEa0B
p0QJW6Q1x2GCk6P76IjBiCvCLclawhm02m2PZr/wcpv+JHcursDU/AATdcj01DZS
/2vLn6ojEKYYrBxTIjW5KDkJlcoiEn5EbsxgrQR3Dug8s1U9qc3tFPMtEFJrbqbW
Q4IrF2VJ4i3d5pJW8HCNGGHmK7kyJC8JmlJ3sE9fslsv9QFJlohmA1UrE4dA5sbb
mzg6A/cl8/xn/+pBpv2lXHbitcaPMYxsLdreOdjDsz/dnG3raoOhQ6f5HAIxcb7h
+CGssuJt7lXk0jl+eeqF/30Sb7QV7kcrSpq9pOuCRLfjd63HVGSlAO3hanOqlNGe
zarVAt1Wv7ALtjk1ddFjb/saIM3YpvIkuebr351yYyvXA0ifTtLt7++xVYDXLEMP
F7Qq5anQ0gVbCRRf0hAm83fBFRaKJc9BU44H285NmPRlr8eEskequ9p79BnKqvJt
9oB7D0OSdmH5kvsmDxB0yTQS+0bGttpgjrK77acY71YC3QH/xm3hvqKvC7ZqwRqJ
SAtPIeuNpuemtTURTx7p
=QCZU
-----END PGP SIGNATURE-----

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


Re: CGI script to work on Tomcat

Posted by Rahul R <ra...@gmail.com>.
This is from my conf/web.xml

 <servlet>
        <servlet-name>cgi</servlet-name>

<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>cgiPathPrefix</param-name>
          <param-value>WEB-INF/cgi</param-value>
        </init-param>
        <init-param>
 <param-name>passShellEnvironment</param-name>
 <param-value>true</param-value>
 </init-param>
<init-param>
          <param-name>executable</param-name>
          <param-value>perl</param-value>
        </init-param>

         <load-on-startup>5</load-on-startup>
    </servlet>


<servlet-mapping>
        <servlet-name>cgi</servlet-name>
        <url-pattern>/cgi-bin/*</url-pattern>
    </servlet-mapping>


Please let me know what do you mean by privileged usage.


On Fri, Jun 20, 2014 at 6:17 PM, André Warnier <aw...@ice-sa.com> wrote:

> Rahul R wrote:
>
>> More info:
>>
>> http://localhost:8180/toggle_read.html is html. But after using
>> <action='./read_toggle.cgi'>
>> in the html the url loading is http://localhost:8180/read_toggle.cgi and
>> again its giving 404 error. :(
>>
>
> Are you listening to what you are told ?
> Did you read https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html ?
> Did you understand it, and did you do all that is mentioned there ?
>
> To prove it, copy and paste here the content of your conf/web.xml file :
> -- start here --
>
>
> -- end here --
>
>
>
>>
>> On Fri, Jun 20, 2014 at 5:59 PM, Rahul R <ra...@gmail.com> wrote:
>>
>>  Thanks Mark for your suggestion. But by privileged, did you mean to add
>>> an
>>> entry like below on context.xml?
>>>
>>> <Context privileged="true">
>>> </Context>
>>>
>>>
>>>
>>> On Fri, Jun 20, 2014 at 5:46 PM, Mark Thomas <ma...@apache.org> wrote:
>>>
>>>  On 20/06/2014 12:49, Rahul R wrote:
>>>>
>>>>> Hi
>>>>>
>>>>>  I am trying to migrate something which was working under apache to
>>>>>
>>>> tomcat.
>>>>
>>>>> I had an html form which takes user input values and pass those values
>>>>>
>>>> and
>>>>
>>>>> executes some cgi scripts. But when I moved html and cgi under tomcat,
>>>>>
>>>> the
>>>>
>>>>> html form is loading properly, but when I click submit, its giving 404
>>>>> error for the cgi execution.
>>>>>
>>>>> I have my html files under ROOT and cgi scripts under ROOT/WEB-INF/cgi
>>>>> Tomcat Version: 7.0.54
>>>>>
>>>>> And in my html form I have mentioned the cgi location as
>>>>> <action='./WEB-INF/cgi/read_toggle.cgi'>
>>>>>
>>>>> I followed the steps mentioned in the below url.
>>>>>
>>>>>
>>>>>  http://www.wellho.net/solutions/java-running-cgi-
>>>> scripts-in-apache-tomcat.html
>>>>
>>>>> I don't see anything in the catalina.out or any other logs. Kindly me
>>>>>
>>>> help
>>>>
>>>>> to fix this issue.
>>>>>
>>>> Try using the real Tomcat documentation rather than some random Google
>>>> result that doesn't even bother to mention which version of Tomcat it
>>>> was written for (hint: it wasn't written for Tomcat 7).
>>>>
>>>> Given how you have configured Tomcat, the behaviour you are seeing is
>>>> exactly as expected. If you want your script to work with the minimum of
>>>> changes you need to:
>>>> - Make your web application privileged
>>>> - Use <action='./read_toggle.cgi'>
>>>>
>>>> Mark
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>> --
>>> Thanks,
>>> Regards,
>>> Rahul R
>>>
>>>   .~.
>>>   /V\
>>>  // \\
>>> /(   )\
>>>  ^`~'^
>>>
>>> Mob: 09008030921
>>>
>>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Thanks,
Regards,
Rahul R

  .~.
  /V\
 // \\
/(   )\
 ^`~'^

Mob: 09008030921

Re: CGI script to work on Tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Rahul R wrote:
> More info:
> 
> http://localhost:8180/toggle_read.html is html. But after using
> <action='./read_toggle.cgi'>
> in the html the url loading is http://localhost:8180/read_toggle.cgi and
> again its giving 404 error. :(

Are you listening to what you are told ?
Did you read https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html ?
Did you understand it, and did you do all that is mentioned there ?

To prove it, copy and paste here the content of your conf/web.xml file :
-- start here --


-- end here --

> 
> 
> On Fri, Jun 20, 2014 at 5:59 PM, Rahul R <ra...@gmail.com> wrote:
> 
>> Thanks Mark for your suggestion. But by privileged, did you mean to add an
>> entry like below on context.xml?
>>
>> <Context privileged="true">
>> </Context>
>>
>>
>>
>> On Fri, Jun 20, 2014 at 5:46 PM, Mark Thomas <ma...@apache.org> wrote:
>>
>>> On 20/06/2014 12:49, Rahul R wrote:
>>>> Hi
>>>>
>>>>  I am trying to migrate something which was working under apache to
>>> tomcat.
>>>> I had an html form which takes user input values and pass those values
>>> and
>>>> executes some cgi scripts. But when I moved html and cgi under tomcat,
>>> the
>>>> html form is loading properly, but when I click submit, its giving 404
>>>> error for the cgi execution.
>>>>
>>>> I have my html files under ROOT and cgi scripts under ROOT/WEB-INF/cgi
>>>> Tomcat Version: 7.0.54
>>>>
>>>> And in my html form I have mentioned the cgi location as
>>>> <action='./WEB-INF/cgi/read_toggle.cgi'>
>>>>
>>>> I followed the steps mentioned in the below url.
>>>>
>>>>
>>> http://www.wellho.net/solutions/java-running-cgi-scripts-in-apache-tomcat.html
>>>> I don't see anything in the catalina.out or any other logs. Kindly me
>>> help
>>>> to fix this issue.
>>> Try using the real Tomcat documentation rather than some random Google
>>> result that doesn't even bother to mention which version of Tomcat it
>>> was written for (hint: it wasn't written for Tomcat 7).
>>>
>>> Given how you have configured Tomcat, the behaviour you are seeing is
>>> exactly as expected. If you want your script to work with the minimum of
>>> changes you need to:
>>> - Make your web application privileged
>>> - Use <action='./read_toggle.cgi'>
>>>
>>> Mark
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>> --
>> Thanks,
>> Regards,
>> Rahul R
>>
>>   .~.
>>   /V\
>>  // \\
>> /(   )\
>>  ^`~'^
>>
>> Mob: 09008030921
>>
> 
> 
> 


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


Re: CGI script to work on Tomcat

Posted by Rahul R <ra...@gmail.com>.
More info:

http://localhost:8180/toggle_read.html is html. But after using
<action='./read_toggle.cgi'>
in the html the url loading is http://localhost:8180/read_toggle.cgi and
again its giving 404 error. :(


On Fri, Jun 20, 2014 at 5:59 PM, Rahul R <ra...@gmail.com> wrote:

> Thanks Mark for your suggestion. But by privileged, did you mean to add an
> entry like below on context.xml?
>
> <Context privileged="true">
> </Context>
>
>
>
> On Fri, Jun 20, 2014 at 5:46 PM, Mark Thomas <ma...@apache.org> wrote:
>
>> On 20/06/2014 12:49, Rahul R wrote:
>> > Hi
>> >
>> >  I am trying to migrate something which was working under apache to
>> tomcat.
>> > I had an html form which takes user input values and pass those values
>> and
>> > executes some cgi scripts. But when I moved html and cgi under tomcat,
>> the
>> > html form is loading properly, but when I click submit, its giving 404
>> > error for the cgi execution.
>> >
>> > I have my html files under ROOT and cgi scripts under ROOT/WEB-INF/cgi
>> > Tomcat Version: 7.0.54
>> >
>> > And in my html form I have mentioned the cgi location as
>> > <action='./WEB-INF/cgi/read_toggle.cgi'>
>> >
>> > I followed the steps mentioned in the below url.
>> >
>> >
>> http://www.wellho.net/solutions/java-running-cgi-scripts-in-apache-tomcat.html
>> >
>> > I don't see anything in the catalina.out or any other logs. Kindly me
>> help
>> > to fix this issue.
>>
>> Try using the real Tomcat documentation rather than some random Google
>> result that doesn't even bother to mention which version of Tomcat it
>> was written for (hint: it wasn't written for Tomcat 7).
>>
>> Given how you have configured Tomcat, the behaviour you are seeing is
>> exactly as expected. If you want your script to work with the minimum of
>> changes you need to:
>> - Make your web application privileged
>> - Use <action='./read_toggle.cgi'>
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
> --
> Thanks,
> Regards,
> Rahul R
>
>   .~.
>   /V\
>  // \\
> /(   )\
>  ^`~'^
>
> Mob: 09008030921
>



-- 
Thanks,
Regards,
Rahul R

  .~.
  /V\
 // \\
/(   )\
 ^`~'^

Mob: 09008030921

Re: CGI script to work on Tomcat

Posted by Rahul R <ra...@gmail.com>.
Thanks Mark for your suggestion. But by privileged, did you mean to add an
entry like below on context.xml?

<Context privileged="true">
</Context>



On Fri, Jun 20, 2014 at 5:46 PM, Mark Thomas <ma...@apache.org> wrote:

> On 20/06/2014 12:49, Rahul R wrote:
> > Hi
> >
> >  I am trying to migrate something which was working under apache to
> tomcat.
> > I had an html form which takes user input values and pass those values
> and
> > executes some cgi scripts. But when I moved html and cgi under tomcat,
> the
> > html form is loading properly, but when I click submit, its giving 404
> > error for the cgi execution.
> >
> > I have my html files under ROOT and cgi scripts under ROOT/WEB-INF/cgi
> > Tomcat Version: 7.0.54
> >
> > And in my html form I have mentioned the cgi location as
> > <action='./WEB-INF/cgi/read_toggle.cgi'>
> >
> > I followed the steps mentioned in the below url.
> >
> >
> http://www.wellho.net/solutions/java-running-cgi-scripts-in-apache-tomcat.html
> >
> > I don't see anything in the catalina.out or any other logs. Kindly me
> help
> > to fix this issue.
>
> Try using the real Tomcat documentation rather than some random Google
> result that doesn't even bother to mention which version of Tomcat it
> was written for (hint: it wasn't written for Tomcat 7).
>
> Given how you have configured Tomcat, the behaviour you are seeing is
> exactly as expected. If you want your script to work with the minimum of
> changes you need to:
> - Make your web application privileged
> - Use <action='./read_toggle.cgi'>
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Thanks,
Regards,
Rahul R

  .~.
  /V\
 // \\
/(   )\
 ^`~'^

Mob: 09008030921

Re: CGI script to work on Tomcat

Posted by Mark Thomas <ma...@apache.org>.
On 20/06/2014 12:49, Rahul R wrote:
> Hi
> 
>  I am trying to migrate something which was working under apache to tomcat.
> I had an html form which takes user input values and pass those values and
> executes some cgi scripts. But when I moved html and cgi under tomcat, the
> html form is loading properly, but when I click submit, its giving 404
> error for the cgi execution.
> 
> I have my html files under ROOT and cgi scripts under ROOT/WEB-INF/cgi
> Tomcat Version: 7.0.54
> 
> And in my html form I have mentioned the cgi location as
> <action='./WEB-INF/cgi/read_toggle.cgi'>
> 
> I followed the steps mentioned in the below url.
> 
> http://www.wellho.net/solutions/java-running-cgi-scripts-in-apache-tomcat.html
> 
> I don't see anything in the catalina.out or any other logs. Kindly me help
> to fix this issue.

Try using the real Tomcat documentation rather than some random Google
result that doesn't even bother to mention which version of Tomcat it
was written for (hint: it wasn't written for Tomcat 7).

Given how you have configured Tomcat, the behaviour you are seeing is
exactly as expected. If you want your script to work with the minimum of
changes you need to:
- Make your web application privileged
- Use <action='./read_toggle.cgi'>

Mark

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