Running cgi-bin on Tomcat: Simple steps & gotchas Atletismo cgi-bin a Tomcat: medidas simples y errores
cgi-bin programs (common executables) can be run from Tomcat. cgi-bin programas (ejecutables comunes) puede ejecutarse desde Tomcat. It is however not enabled by default. Es sin embargo no está activo por defecto.
To enable it carefully follow the steps below: Para que pueda seguir cuidadosamente los pasos a continuación:
1. Uncomment (or add) the following sections to $CATALINA_HOME/conf/web.xml (%CATALINA_HOME%\conf\web.xml on windows), between the Descomentar (o añadir) las siguientes secciones a $ CATALINA_HOME / conf / web.xml (% CATALINA_HOME% \ conf \ web.xml en las ventanas), entre el
2. Rename the $CATALINA_HOME/server/lib/servlets-cgi.renametojar (%CATALINA_HOME%\server\lib\servlets-cgi.renametojar on windows) file to $CATALINA_HOME/server/lib/servlets-cgi.jar (%CATALINA_HOME%\server\lib\servlets-cgi.jar on windows) Cambiar nombre de los $ CATALINA_HOME / servidor / lib / Servlets-cgi.renametojar (% CATALINA_HOME% \ servidor \ lib \ servlets-cgi.renametojar en las ventanas) archivo en $ CATALINA_HOME / servidor / lib / Servlets-cgi.jar (% CATALINA_HOME% \ servidor \ lib \ servlets-cgi.jar en las ventanas)
3. Restart Tomcat Reinicie Tomcat
Testing with Hello.bat Pruebas con Hello.bat
A simple way to test would be to create a cgi directory under WEB-INF directory of your Web application. Una manera sencilla de prueba sería la creación de un directorio cgi bajo WEB-INF directorio de su aplicación Web.
Lets add a simple file called hello.bat (for windows users). Permite añadir un simple archivo llamado hello.bat (para usuarios de Windows).
The file contains just the line: El archivo contiene sólo la línea:
echo Hello World! echo Hello World!
This displays the String “Hello World!” Esto muestra la cadena "Hello World!"
Create a file called env.bat Crear un archivo llamado env.bat
The file contains just the line: El archivo contiene sólo la línea:
set establecer
This displays all the available environment variables for the cgi-bin program. Esta muestra todas las variables de entorno disponibles para el cgi-bin programa.
Gotchas on windows Errores en Windows
—————— ------
Normally we use @echo off in a batch file to turn off displaying the command. Normalmente usamos @ echo off en un fichero por lotes, para desactivar la visualización de comando. However when we do the following, no output is displayed: Sin embargo, cuando hacemos el siguiente, no se visualiza salida:
@echo off @ echo off
echo Hello World! echo Hello World!
It just needs a newline to be happy. Sólo necesita una nueva línea para ser feliz. So create a file (say empty.txt) which just contains a newline. Por lo tanto, crear un archivo (por ejemplo empty.txt) que sólo contiene una nueva línea. Then change hello.bat to the following: Luego cambio hello.bat a lo siguiente:
@echo off @ echo off
type empty.txt tipo empty.txt
echo Hello World! echo Hello World!
echo on echo on
This works as intended. Esto funciona según lo previsto.
Note: Would you like to show a Nota: ¿Le gustaría mostrar un token of appreciation muestra de agradecimiento for my hard work? para mi duro trabajo? I enjoy a cup of Me gusta una taza de Cafe Estima Blend Cafe estima Blend from Starbucks. de Starbucks.
Filed under Filed under Headline News Headline News , How To Cómo , Java Software El software de Java | |
| |
RSS 2.0 RSS 2,0 | |
Email this Article Enviar artículo
You may also like to read También puede leer |





April 23rd, 2004 at 1:07 pm 23 de abril de 2004 a las 1:07 pm
Don’t forget to uncomment the servlet-mapping for cgi No olvide descomentar el servlet-mapping para cgi
December 11th, 2004 at 2:11 pm Diciembre 11, 2004 a las 2:11 pm
I did at the bottom. Lo hice en la parte inferior.
March 25th, 2005 at 1:58 pm 25 de marzo, de 2005 a las 1:58 pm
I had to specify an executable init param equal to the full path of perl in order to get this to work. He tenido que especificar un ejecutable de inicio param igual a la ruta completa de perl con el fin de conseguir que esto funcione.
executable ejecutable
full path of perl ruta completa de Perl
I am not sure why I had to do this since perl should already be in the path. No estoy seguro de por qué tuve que hacer esto desde perl ya debería estar en el camino. I’m running TomCat 5 on Windows XP Professional. Estoy corriendo Tomcat 5 en Windows XP Professional.
April 4th, 2005 at 3:14 pm 4 de abril de 2005, a las 3:14 pm
@Giles Specifying full-path looks logical to me. @ Giles Especificar completo camino parece lógico para mí. Java doesn’t invoke executables by looking at the path variable. Java no invocar ejecutables en busca de la variable PATH.
May 6th, 2005 at 1:43 am Mayo 6, 2005 a las 1:43 am
Add Agregar
executable ejecutable
or (windows xp) o (Windows XP)
executable ejecutable
cmd /c cmd / c
May 6th, 2005 at 1:47 am Mayo 6, 2005 a las 1:47 am
add agregar
param-name=executable param-name = ejecutable
value= value =
or (windows xp) o (Windows XP)
param-name=executable param-name = ejecutable
value=cmd /c value = cmd / c
May 6th, 2005 at 1:49 am Mayo 6, 2005 a las 1:49 am
Directly add executables including batch files. Añadir directamente ejecutables incluidos los archivos por lotes.
However if your want to execute cmd commands like dir then you will have to use cmd /c dir. Sin embargo, si tu quieres ejecutar cmd comandos como dir entonces usted tendrá que usar cmd / c dir.
October 4th, 2005 at 5:04 am 4 de Octubre, 2005 a las 5:04 am
December 2nd, 2005 at 4:55 am 2 de diciembre de 2005, a las 4:55 am
hi all.can anybody help me to send and receive mail from my localhost.im using tomcat5 as my localserver.plz help me out..thanks to all hi all.can a nadie que me ayude a enviar y recibir correo de mi localhost.im tomcat5 utilizando como localserver.plz mi me ayudan a cabo .. gracias a todos
December 2nd, 2005 at 7:24 am 2 de diciembre de 2005, a las 7:24 am
Hi Rock, Hola Rock,
Please refer to this article - Por favor, consulte este artículo --
How to Send / Receive Emails (SMTP & POP) From Localhost; Simple Freeware MailServer Cómo enviar / recibir correos electrónicos (SMTP y POP) de Localhost; simple MailServer Freeware
It has been written to address your question. Ha sido escrito para hacer frente a su pregunta.
Best, Mejor,
Angsuman
December 15th, 2005 at 10:14 am 15 de diciembre de 2005, a las 10:14 am
Please, what is the URL that I shoul enter in order to get the cgi executed? Por favor, ¿cuál es la URL que yo shoul entrar con el fin de obtener el cgi de ejecución?
Does the url below shouldn’t work? ¿La url a continuación no debe trabajar? it isn’t. no lo es.
http:localhost:8080//cgi-bin/foo.sh
thanks gracias
Breno Leitão Breno Leitão
December 15th, 2005 at 11:44 am 15 de diciembre de 2005, a las 11:44 am
Try: Intente:
http://localhost:8080/Your web application directory]/cgi-bin/foo.sh aplicación web directorio] / cgi-bin/foo.sh
Please closely follow the instructions above. Por favor, seguir de cerca las instrucciones anteriores.
April 20th, 2006 at 12:42 pm 20 de abril de 2006, a las 12:42 pm
I have been trying to put perl scripts in webapps/ROOT/WEB-INF/cgi-bin: He estado tratando de poner los scripts de Perl en webapps / ROOT / WEB-INF / cgi-bin:
A) printEnv.cgi A) printEnv.cgi
#!/usr/bin/perl #! / usr / bin / perl
print “Content-type: text/html\n\n”; print "Content-Type: text / html \ n \ n";
print “\n”; print "\ n";
foreach $key (sort keys(%ENV)) { foreach $ key (tipo teclas (% ENV)) (
print “$key = $ENV{$key}”; print "$ key = $ ENV ($ key)";
} )
B) Changes to web.xml B) Los cambios en web.xml
cgi CGI
org.apache.catalina.servlets.CGIServlet
executable ejecutable
/usr/bin/perl / usr / bin / perl
clientInputTimeout
100
debug
6
cgiPathPrefix
WEB-INF/cgi-bin
5
cgi CGI
/cgi-bin/* / cgi-bin / *
D) Renamed to servlets-cgi.jar D) a renombrados servlets-cgi.jar
E) Restarted server E) reinició servidor
But when I do: Pero cuando lo hago:
http://mydomain/cgi-bin/printEnv.cgi
it does not go to the URL no vaya a la URL
April 28th, 2006 at 12:24 pm 28 de abril de 2006, a las 12:24 pm
The steps have worked perfectly for many including myself. Las medidas han funcionado perfectamente durante muchos entre los que me incluyo.
Unfortunately I don’t have time at this moment to support your specific issue. Por desgracia no tengo tiempo en este momento para apoyar a su problema específico.
April 25th, 2007 at 1:47 pm 25 de abril de 2007, a las 1:47 pm
Hi, Hola,
I followed the steps but I cannot start bat file as cgi script on WinXP. He seguido los pasos pero no puedo empezar bat como script cgi en WinXP. The error is: “java.io.IOException: Cannot run program “perl” (in directory “C:\Program Files\Tomcat 5.5\webapps\test\WEB-INF\cgi”) El error es: "java.io.IOException: No se puede ejecutar el programa" perl "(en el directorio" C: \ Archivos de programa \ Tomcat 5,5 \ webapps \ test \ WEB-INF \ cgi ")
I tried to add He intentado añadir
param-name=executable param-name = ejecutable
value=cmd /c value = cmd / c
or param-name=executable o param-name = ejecutable
value=cmd cmd = valor
but without success. pero sin éxito. Any ideas? ¿Ideas?
October 19th, 2007 at 3:37 am Octubre 19, 2007 a las 3:37 am
test.cgi is : test.cgi es:
#!\perl\bin\perl.exe#! \ perl \ bin \ perl.exeprint “Content-type: text/html\n\n”; print "Content-Type: text / html \ n \ n";
print “IN TEST!\n”; print "EN TEST! \ n";
print “\n”; print "\ n";
print “IN TEST!\n”; print "EN TEST! \ n";
print “\n”; print "\ n";
Store Location of test.cgi is : webapps/test/ Ubicación de la tienda test.cgi es: webapps / test /
Output in La producción en http://localhost:8080/test/test.cgi http://localhost:8080/test/test.cgi
#!\perl\bin\perl.exe print “Content-type: text/html\n\n”; print “\n”; print “\n”; print “#! \ perl \ bin \ perl.exe print "Content-Type: text / html \ n \ n"; print "\ n"; print "\ n"; print "IN TEST!EN PRUEBA!\n”; print “\n”;\ n "; print" \ n ";October 19th, 2007 at 3:48 am Octubre 19, 2007 a las 3:48 am
Please help me to fix the working of CGI which I mentioned above. Por favor, me ayudan a solucionar el trabajo de CGI que he mencionado más arriba. I am not able to execute ang CGI through TOMCAT. Yo no soy capaz de ejecutar ang CGI a través de Tomcat.