title: Why can't I start tomcat using catalina in a shell script
body: <p>I'm curious of how su -c "cmd arg" and tomcat works within a shell script.</p>
  
  <p>Manually from the cmd line, I ran:</p>
  
  <pre><code>su -m tomcat -c /path/to/tomcat/catalina.sh start
  </code></pre>
  
  <p>This didn't work.  However, if I put the cmd in quotes, it worked</p>
  
  <pre><code>su -m tomcat -c "/path/catalina.sh start"
  </code></pre>
  
  <p>Within a shell script (trying to run chkconfig so it starts automatically), I have something like this:</p>
  
  <pre><code>START="/path/catalina.sh start"
  ...
  ...
  su -m tomcat -c "$START"
  </code></pre>
  
  <p>The command is in quotes since I found out manually that quotes are required.
  When I run the script, the output comes back as:</p>
  
  <pre><code>Using CATALINA_BASE:   /apps/local/apache-tomcat-7.0.42
  Using CATALINA_HOME:   /apps/local/apache-tomcat-7.0.42
  Using CATALINA_TMPDIR: /apps/local/apache-tomcat-7.0.42/temp
  Using JRE_HOME:        /usr/java/default
  Using CLASSPATH:       /apps/local/apache-tomcat-7.0.42/bin/bootstrap.jar:/apps/local/apache-tomcat-7.0.42/bin/tomcat-juli.jar
  Usage: catalina.sh ( commands ... )
  commands:
    debug             Start Catalina in a debugger
    debug -security   Debug Catalina with a security manager
    jpda start        Start Catalina under JPDA debugger
    run               Start Catalina in the current window
    run -security     Start in the current window with security manager
    start             Start Catalina in a separate window
    start -security   Start in a separate window with security manager
    stop              Stop Catalina, waiting up to 5 seconds for the process to end
    stop n            Stop Catalina, waiting up to n seconds for the process to end
    stop -force       Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
    stop n -force     Stop Catalina, wait up to n seconds and then use kill -KILL if still running
    configtest        Run a basic syntax check on server.xml - check exit code for result
    version           What version of tomcat are you running?
  Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined
  </code></pre>
  
  <p>This output is like if I manually ran catalina.sh w/o any start/stop arguments. <br>Why is the start/stop option being ignored in the shell script?  Yes, I replaced catalina.sh with startup.sh and shutdown.sh and that made the script work but I'm still curious why inside a script, su -c "cmd arg" seemed to ignore the argument portion of the command.</p>
  
  <p>Thanks in advance for your explanation.  I'll shoot myself if it's something as easy as shell expansion and quote removal unless I do something to make it not lose the quote.</p>