Bug 37848 - Inappropriate Output From catalina.sh When No Terminal Available
Summary: Inappropriate Output From catalina.sh When No Terminal Available
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.13
Hardware: All All
: P4 trivial (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-09 00:32 UTC by David Shaw
Modified: 2009-11-30 16:34 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Shaw 2005-12-09 00:32:04 UTC
bin/catalina.sh issues some informational output to "stdout" when executed. If
Tomcat is being started by a Unix init script (ie. as part of the boot process),
then this output disrupts the boot messages. It would be useful if this output
was only issued when Tomcat is being started from the command line.

A simple patch is included below:

-----patch file-----------------------------------------------------------------
--- catalina.sh 2005-12-09 10:22:44.000000000 +1100
+++ catalina.sh 2005-12-09 10:24:30.000000000 +1100
@@ -131,6 +131,11 @@
   CATALINA_TMPDIR="$CATALINA_BASE"/temp
 fi

+have_tty=0
+if [ "`tty`" != "not a tty" ]; then
+    have_tty=1
+fi
+
 # For Cygwin, switch paths to Windows format before running java
 if $cygwin; then
   JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
@@ -150,13 +155,15 @@

 # ----- Execute The Requested Command -------------------------------


-echo "Using CATALINA_BASE:   $CATALINA_BASE"
-echo "Using CATALINA_HOME:   $CATALINA_HOME"
-echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
-if [ "$1" = "debug" -o "$1" = "javac" ] ; then
-  echo "Using JAVA_HOME:       $JAVA_HOME"
-else
-  echo "Using JRE_HOME:       $JRE_HOME"
+if [ $have_tty -eq 1 ]; then
+  echo "Using CATALINA_BASE:   $CATALINA_BASE"
+  echo "Using CATALINA_HOME:   $CATALINA_HOME"
+  echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
+  if [ "$1" = "debug" -o "$1" = "javac" ] ; then
+    echo "Using JAVA_HOME:       $JAVA_HOME"
+  else
+    echo "Using JRE_HOME:       $JRE_HOME"
+  fi
 fi

 if [ "$1" = "jpda" ] ; then
Comment 1 Yoav Shapira 2006-04-14 15:24:41 UTC
Good idea, applied.
Comment 2 Eric Herman 2009-09-30 00:48:42 UTC
Shouldn't the "Using Security Manager" messages be similarly guarded?


diff -Naur original/apache-tomcat-6.0.20/bin/catalina.sh bug37848/apache-tomcat-6.0.20/bin/catalina.sh
--- original/apache-tomcat-6.0.20/bin/catalina.sh	2009-05-14 01:15:04.000000000 +0200
+++ bug37848/apache-tomcat-6.0.20/bin/catalina.sh	2009-09-30 09:33:54.000000000 +0200
@@ -241,7 +241,9 @@
   else
     shift
     if [ "$1" = "-security" ] ; then
-      echo "Using Security Manager"
+      if [ $have_tty -eq 1 ]; then
+        echo "Using Security Manager"
+      fi
       shift
       exec "$_RUNJDB" "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
         -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
@@ -267,7 +269,9 @@
 
   shift
   if [ "$1" = "-security" ] ; then
-    echo "Using Security Manager"
+    if [ $have_tty -eq 1 ]; then
+      echo "Using Security Manager"
+    fi
     shift
     exec "$_RUNJAVA" "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
       -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
@@ -291,7 +295,9 @@
   shift
   touch "$CATALINA_BASE"/logs/catalina.out
   if [ "$1" = "-security" ] ; then
-    echo "Using Security Manager"
+    if [ $have_tty -eq 1 ]; then
+      echo "Using Security Manager"
+    fi
     shift
     "$_RUNJAVA" "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
       -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
Comment 3 Mark Thomas 2009-10-21 14:42:23 UTC
Thanks for the patch

This has been applied to trunk and proposed for 6.0.x and 5.5.x
Comment 4 Mark Thomas 2009-11-30 16:34:04 UTC
The patch has been applied to 5.5.x and will be included in 5.5.29 onwards. It
has also been applied to 6.0.x and will be in 6.0.21 onwards.