Welcome to LQ.
Quote:
Originally Posted by bealefay
Can someone please suggest how to change the path ?
|
"cd <path>" - in your script.
However you may not need to do this.
Quote:
Originally Posted by bealefay
I am trying to find the installed tomcat version and location of the server.xml file to get the tomcat port number.
|
The whole locating of version.sh may be a loaded problem. Who's to say if there aren't several version.sh and six of the several are not related to Tomcat.
Perhaps you ought to find out the execution location for tomcat. I'm not familiar with running it, but whatever you would use to run it, you could use the "which" command to find out the path for it. You could next test that path to find out the existence, or not, of version.sh, and then you can run that script and parse the output. All of this you can do either by changing directory in your script, as shown above in my top statement how to change the path, or you can likely do that all without changing the path and just run version.sh using the fully qualified pathname for it.
As in the command line, you can run a program if you're in the directory for it, or you can run it using the path for it. And further, if the executable is in your actual $PATH environment variable, then you can run it anyways, without specifying the path. As always, I'd recommend what several may also say, to script defensively, using no assumptions, and just use the full paths as much as possible.
Edit additional:
And what executable (Tomcat) does not support command line arguments such as -v, --version, or similar? In short, why would you need the version.sh script. Or it is solely doing the command line switches? Review that script and figure out why it is anything special.