From Command Line
To find the version of Tomcat from the command line:
java -cp {tomcat home directory}/lib/catalina.jar org.apache.catalina.util.ServerInfoThe result will look like:
Server version: Apache Tomcat/7.0.52 Server built: Feb 13 2014 10:24:25 Server number: 7.0.52.0 OS Name: Mac OS X OS Version: 10.11.3 Architecture: x86_64 JVM Version: 1.7.0_75-b13 JVM Vendor: Oracle CorporationIf Tomcat is running, you can use this script to show its version. It looks for Tomcat among the running processes and uses the command line options specified (catalina.base or catalina.home) when it was started to find the home directory.
#!/bin/bash # If Tomcat is running, display its version. # # This script looks for Tomcat among running process and locates its # home directory from the command line options specified when it was # started, either in catalina.base or catalina.home. # # Trick: use grep "[c]atalina.base" and awk "[c]atalina.base" so the # regular expression won't match itself and return 2 results. # "grep [c]atalina.base" does not match the string "grep [c]atalina.base". # Try doing "ps -ef | grep catalina.base" and see that it returns 2 results. # Try doing "ps -ef | grep [c]atalina.base" and see that it returns 1 result. TOMCAT_DIR=`ps -ef | grep "[c]atalina.base" | awk -F "[c]atalina.base=" '{print $2}' | cut -d ' ' -f 1` if [ -z "$TOMCAT_DIR" ]; then TOMCAT_DIR=`ps -ef | grep "[c]atalina.home" | awk -F "[c]atalina.home=" '{print $2}' | cut -d ' ' -f 1` if [ -z "$TOMCAT_DIR" ]; then echo "Tomcat does not appear to be running." echo -e "If you know where the Tomcat home directory is, you can find the version by running:\n" echo -e "java -cp {tomcat home directory}/lib/catalina.jar org.apache.catalina.util.ServerInfo\n" exit 1 fi fi echo -e "Tomcat is running.\n" echo -e "Home directory: $TOMCAT_DIR\n" java -cp $TOMCAT_DIR/lib/catalina.jar org.apache.catalina.util.ServerInfoRemember to make the file executable with "chmod a+x filename".
No comments:
Post a Comment