Running cgi-bin on Tomcat: Simple steps & gotchas Running cgi-bin sur Tomcat: des mesures simples et pièges courants
cgi-bin programs (common executables) can be run from Tomcat. cgi-bin programmes (exécutables commun) peut être utilisé par Tomcat. It is however not enabled by default. Il n'est cependant pas activé par défaut.
To enable it carefully follow the steps below: Pour lui permettre de suivre attentivement les étapes ci-dessous:
1. Uncomment (or add) the following sections to $CATALINA_HOME/conf/web.xml (%CATALINA_HOME%\conf\web.xml on windows), between the Décommenter (ou ajouter) les sections suivantes à $ CATALINA_HOME / conf / web.xml (% CATALINA_HOME% \ conf \ web.xml sur les fenêtres), entre le
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) Renommer l'$ CATALINA_HOME / server / lib / servlet-cgi.renametojar (% CATALINA_HOME% \ server \ lib \ servlets-cgi.renametojar sur les fenêtres) file à $ CATALINA_HOME / server / lib / servlet-cgi.jar (% CATALINA_HOME% \ serveur \ lib \ servlets-cgi.jar sur les fenêtres)
3. Restart Tomcat Redémarrez Tomcat
Testing with Hello.bat Essais avec Hello.bat
A simple way to test would be to create a cgi directory under WEB-INF directory of your Web application. Un moyen simple de tester serait de créer un répertoire cgi sous WEB-INF de votre application Web.
Lets add a simple file called hello.bat (for windows users). Permet d'ajouter un simple fichier appelé hello.bat (Pour les utilisateurs de Windows).
The file contains just the line: Le fichier contient la ligne:
echo Hello World! echo Bonjour tout le monde!
This displays the String “Hello World!” Cela affiche la chaîne "Bonjour le monde!"
Create a file called env.bat Créer un fichier nommé env.bat
The file contains just the line: Le fichier contient la ligne:
set définir
This displays all the available environment variables for the cgi-bin program. Cela affiche toutes les variables d'environnement pour le cgi-bin.
Gotchas on windows Pièges sur les fenêtres
—————— ------
Normally we use @echo off in a batch file to turn off displaying the command. Normalement, nous utilisons @ echo off dans un fichier batch pour désactiver l'affichage de commande. However when we do the following, no output is displayed: Toutefois, lorsque nous faire les choses suivantes, pas de sortie est affichée:
@echo off @ echo off
echo Hello World! echo Bonjour tout le monde!
It just needs a newline to be happy. Il a juste besoin d'un retour à la ligne pour être heureux. So create a file (say empty.txt) which just contains a newline. Ainsi, créer un fichier (par exemple empty.txt) qui ne contient qu'un retour à la ligne. Then change hello.bat to the following: Ensuite, changez de hello.bat sur les points suivants:
@echo off @ echo off
type empty.txt Type de empty.txt
echo Hello World! echo Bonjour tout le monde!
echo on echo sur
This works as intended. Cela fonctionne comme prévu.
Note: Would you like to show a Note: Désirez-vous faire preuve d'une token of appreciation témoignage de reconnaissance for my hard work? pour mon travail? I enjoy a cup of J'aime une tasse de Cafe Estima Blend Mélange de café estimation from Starbucks. de Starbucks.
Filed under Classé sous Headline News Headline News , How To Comment , Java Software Logiciel de Java | |
| |
RSS 2.0 RSS 2,0 | |
Email this Article Envoyer cet article
You may also like to read Vous mai également à lire |





April 23rd, 2004 at 1:07 pm Avril 23, 2004 at 1:07 pm
Don’t forget to uncomment the servlet-mapping for cgi Ne pas oublier de supprimer le servlet-mapping pour CGI
December 11th, 2004 at 2:11 pm Décembre 11, 2004 at 2:11 pm
I did at the bottom. Je n'ai au fond.
March 25th, 2005 at 1:58 pm Mars 25, 2005 at 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. J'ai dû préciser un exécutable init param égal au chemin d'accès complet de perl afin d'obtenir que cela fonctionne.
executable exécutable
full path of perl chemin complet de Perl
I am not sure why I had to do this since perl should already be in the path. Je ne sais pas pourquoi je devais le faire depuis perl devrait déjà être dans le chemin. I’m running TomCat 5 on Windows XP Professional. Je cours Tomcat 5 sur Windows XP Professionnel.
April 4th, 2005 at 3:14 pm Le 4 avril 2005 à 3:14 pm
@Giles Specifying full-path looks logical to me. @ Giles Spécification plein chemin semble logique pour moi. Java doesn’t invoke executables by looking at the path variable. Java ne pas invoquer des exécutables en regardant la variable PATH.
May 6th, 2005 at 1:43 am 6 mai 2005 à 1:43 am
Add Ajouter
executable exécutable
or (windows xp) ou (Windows XP)
executable exécutable
cmd /c cmd / c
May 6th, 2005 at 1:47 am 6 mai 2005 à 1:47 am
add ajouter
param-name=executable - param name = exécutable
value= value =
or (windows xp) ou (Windows XP)
param-name=executable - param name = exécutable
value=cmd /c value = cmd / c
May 6th, 2005 at 1:49 am 6 mai 2005 à 1:49 am
Directly add executables including batch files. Ajouter directement exécutables y compris fichiers batch.
However if your want to execute cmd commands like dir then you will have to use cmd /c dir. Toutefois, si votre voulez exécuter des commandes comme cmd dir alors vous devrez utiliser cmd / c dir.
October 4th, 2005 at 5:04 am 4 octobre 2005 à 5:04 am
December 2nd, 2005 at 4:55 am Décembre 2nd, 2005 at 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 salut tout le monde all.can m'aider à envoyer et recevoir des e-mails de mon localhost.im tomcat5 utilisant comme mon localserver.plz m'aider à .. merci à tous
December 2nd, 2005 at 7:24 am Décembre 2nd, 2005 at 7:24 am
Hi Rock, Salut Rock,
Please refer to this article - S’il vous plaît se référer à cet article --
How to Send / Receive Emails (SMTP & POP) From Localhost; Simple Freeware MailServer Comment envoyer / recevoir des e-mails (SMTP et POP) de Localhost; simple Freeware MailServer
It has been written to address your question. Il a été écrit pour répondre à votre question.
Best, Meilleur,
Angsuman
December 15th, 2005 at 10:14 am Décembre 15 septembre 2005 à 10:14 am
Please, what is the URL that I shoul enter in order to get the cgi executed? S’il vous plaît, ce qui est l'URL que je shoul entrer pour obtenir le cgi exécutés?
Does the url below shouldn’t work? T-elle l'URL ci-dessous ne devraient pas travailler? it isn’t. il ne l'est pas.
http:localhost:8080//cgi-bin/foo.sh
thanks merci
Breno Leitão Breno Leitão
December 15th, 2005 at 11:44 am Décembre 15, 2005 at 11:44 am
Try: Essayez:
http://localhost:8080/Your web application directory]/cgi-bin/foo.sh application web directory] / cgi-bin/foo.sh
Please closely follow the instructions above. S’il vous plaît suivre de près les instructions ci-dessus.
April 20th, 2006 at 12:42 pm Avril 20th, 2006 at 12:42 pm
I have been trying to put perl scripts in webapps/ROOT/WEB-INF/cgi-bin: J'ai essayé de mettre les scripts perl dans 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 (clé de tri (% ENV)) (
print “$key = $ENV{$key}”; print "$ key = $ ENV ($ key)";
} )
B) Changes to web.xml B) Les modifications apportées à web.xml
cgi CGI
org.apache.catalina.servlets.CGIServlet
executable exécutable
/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) Devenu servlets-cgi.jar
E) Restarted server E) redémarré le serveur
But when I do: Mais quand je fais:
http://mydomain/cgi-bin/printEnv.cgi
it does not go to the URL il ne va pas à l'URL
April 28th, 2006 at 12:24 pm Avril 28th, 2006 à 12:24 pm
The steps have worked perfectly for many including myself. Les mesures ont fonctionné parfaitement pendant de nombreuses dont moi-même.
Unfortunately I don’t have time at this moment to support your specific issue. Malheureusement, je n'ai pas le temps en ce moment à l'appui de votre question spécifique.
April 25th, 2007 at 1:47 pm Avril 25, 2007 at 1:47 pm
Hi, Salut,
I followed the steps but I cannot start bat file as cgi script on WinXP. J'ai suivi les étapes mais je ne peux pas commencer bat comme script CGI sur WinXP. The error is: “java.io.IOException: Cannot run program “perl” (in directory “C:\Program Files\Tomcat 5.5\webapps\test\WEB-INF\cgi”) L'erreur est: "java.io.IOException: Impossible d'exécuter le programme" perl "(dans le répertoire" C: \ Program Files \ 5,5 Tomcat \ webapps \ test \ WEB-INF \ cgi ")
I tried to add J'ai essayé d'ajouter
param-name=executable - param name = exécutable
value=cmd /c value = cmd / c
or param-name=executable ou-param name = exécutable
value=cmd cmd = valeur
but without success. mais sans succès. Any ideas? Des idées?
October 19th, 2007 at 3:37 am Octobre 19, 2007 at 3:37 am
test.cgi is : test.cgi est:
#!\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 phase de test! \ n";
print “\n”; print "\ n";
print “IN TEST!\n”; print "en phase de test! \ n";
print “\n”; print "\ n";
Store Location of test.cgi is : webapps/test/ Emplacement du magasin de test.cgi est la suivante: webapps / test /
Output in La production de 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 test!\n”; print “\n”;\ n "; print" \ n ";October 19th, 2007 at 3:48 am Octobre 19, 2007 at 3:48 am
Please help me to fix the working of CGI which I mentioned above. S’il vous plaît aidez-moi à fixer le travail de CGI dont j'ai parlé ci-dessus. I am not able to execute ang CGI through TOMCAT. Je ne suis pas en mesure d'exécuter par CGI the Tomcat.