funkman 2004/06/30 08:25:32 Modified: catalina/src/bin catalina.bat catalina.sh catalina/src/share/org/apache/catalina/util ServerInfo.java Added: catalina/src/bin version.bat version.sh Log: Add new version utility. Allows one to see their version of tomcat without having to startup tomcat or anything else special. This should get rid of the common question: What version of tomcat am I running This worked fine in windows[cmd shell] and cygwin. Revision Changes Path 1.10 +8 -1 jakarta-tomcat-catalina/catalina/src/bin/catalina.bat Index: catalina.bat =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/bin/catalina.bat,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- catalina.bat 26 May 2004 20:04:01 -0000 1.9 +++ catalina.bat 30 Jun 2004 15:25:31 -0000 1.10 @@ -106,6 +106,7 @@ if ""%1"" == ""run"" goto doRun if ""%1"" == ""start"" goto doStart if ""%1"" == ""stop"" goto doStop +if ""%1"" == ""version"" goto doVersion echo Usage: catalina ( commands ... ) echo commands: @@ -117,6 +118,7 @@ echo start Start Catalina in a separate window echo start -security Start in a separate window with security manager echo stop Stop Catalina +echo version What version of tomcat are you running? goto end :doDebug @@ -155,6 +157,11 @@ shift set ACTION=stop goto execCmd + +:doVersion +%_EXECJAVA% -classpath "%CATALINA_HOME%\server\lib\catalina.jar" org.apache.catalina.util.ServerInfo +goto end + :execCmd rem Get remaining unshifted command line arguments and save them in the 1.14 +8 -1 jakarta-tomcat-catalina/catalina/src/bin/catalina.sh Index: catalina.sh =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/bin/catalina.sh,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- catalina.sh 26 May 2004 19:45:33 -0000 1.13 +++ catalina.sh 30 Jun 2004 15:25:31 -0000 1.14 @@ -254,6 +254,12 @@ fi fi +elif [ "$1" = "version" ] ; then + + "$_RUNJAVA" \ + -classpath "$CATALINA_HOME/server/lib/catalina.jar" \ + org.apache.catalina.util.ServerInfo + else echo "Usage: catalina.sh ( commands ... )" @@ -272,6 +278,7 @@ echo " start -security Start in a separate window with security manager" echo " stop Stop Catalina" echo " stop -force Stop Catalina (followed by kill -KILL)" + echo " version What version of tomcat are you running?" exit 1 fi 1.1 jakarta-tomcat-catalina/catalina/src/bin/version.bat Index: version.bat =================================================================== @echo off if "%OS%" == "Windows_NT" setlocal rem --------------------------------------------------------------------------- rem Version script for the CATALINA Server rem rem $Id: version.bat,v 1.1 2004/06/30 15:25:31 funkman Exp $ rem --------------------------------------------------------------------------- rem Guess CATALINA_HOME if not defined set CURRENT_DIR=%cd% if not "%CATALINA_HOME%" == "" goto gotHome set CATALINA_HOME=%CURRENT_DIR% if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome cd .. set CATALINA_HOME=%cd% cd %CURRENT_DIR% :gotHome if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome echo The CATALINA_HOME environment variable is not defined correctly echo This environment variable is needed to run this program goto end :okHome set EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat rem Check that target executable exists if exist "%EXECUTABLE%" goto okExec echo Cannot find %EXECUTABLE% echo This file is needed to run this program goto end :okExec rem Get remaining unshifted command line arguments and save them in the set CMD_LINE_ARGS= :setArgs if ""%1""=="""" goto doneSetArgs set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 shift goto setArgs :doneSetArgs call "%EXECUTABLE%" version %CMD_LINE_ARGS% :end 1.1 jakarta-tomcat-catalina/catalina/src/bin/version.sh Index: version.sh =================================================================== #!/bin/sh # ----------------------------------------------------------------------------- # Version Script for the CATALINA Server # # $Id: version.sh,v 1.1 2004/06/30 15:25:31 funkman Exp $ # ----------------------------------------------------------------------------- # resolve links - $0 may be a softlink PRG="$0" while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done PRGDIR=`dirname "$PRG"` EXECUTABLE=catalina.sh # Check that target executable exists if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then echo "Cannot find $PRGDIR/$EXECUTABLE" echo "This file is needed to run this program" exit 1 fi exec "$PRGDIR"/"$EXECUTABLE" version "$@" 1.3 +8 -4 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/ServerInfo.java Index: ServerInfo.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/ServerInfo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ServerInfo.java 27 Feb 2004 14:58:50 -0000 1.2 +++ ServerInfo.java 30 Jun 2004 15:25:31 -0000 1.3 @@ -1,12 +1,12 @@ /* * Copyright 1999,2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -71,5 +71,9 @@ } + + public static void main(String args[]) { + System.out.println("Version: " + getServerInfo()); + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]