tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pascal Bleser <>
Subject Re: Why cannot I put JSVC into a shell script to run
Date Fri, 01 Sep 2006 16:08:58 GMT
Patrick Wang wrote:
> Thanks for the reply, you are correct. The same command line doesnot work when I
> put into a shell command. I used the command netstat to see if Tomcat has
> started since it listen to the port.

Rather use lsof -i instead of netstat + having to grep the output:

if lsof -i:8080 &>/dev/null; then
  # something is listening on 8080
  # nothing is listening on 8080

Another approach is to use netcat in "zero I/O mode" to make a TCP
connect on the port:

if netcat -n -w 1 -z localhost 8080; then
  # something responds to connect on 8080
  # nothing responds to connect on 8080

 -n is to avoid host and protocol name lookups
 -w 1 is to set the timeout for the connect to 1 second
 -z is for "zero I/O mode" -- i.e. just connect() and close

> Command from console works, starting shell script not working without an error
> shown up on the console.

Just a wild guess: what about your JAVA_HOME, JRE_HOME and other
environment variables that affect Tomcat ?

Are you starting that shell script from the same environment as when
you do it with the command, directly ?
Same environment means: same user, also from an interactive shell, etc...

If, for example, that shell script is being started by init as root,
you will end up having a totally different environment as when you log
in into an interactive shell.

> Since I am new to the bash shell script, I am not sure how to debug it.

bash -x ./

> I checked the catalina.err, it seems cannot find a file, classpath was not
> setup? But everything in the console works great. Could the environment on the
> console and shell script different?

See above.

Personally, I always setup the full environment (well, at least the
environment variables that affect Tomcat) in bin/
If that file exists, it will automatically be sourced by

That's where you should do your environment settings, especially
Do not rely on the environment as it is setup by an interactive login
(e.g. ~/.profile or ~/.bashrc)

JAVA_OPTS="-Xms128m -Xmx128m"

  -o) Pascal Bleser               ATOS Worldline/Aachen(DE)
  /\\   System Architect              WLP Business Platform
 _\_v "Really, I'm not out to destroy Microsoft.  That will
just be a completely unintentional side effect."-L.Torvalds

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message