First and foremost, if I have posted this question in the wrong forum/section, I apologize.
Okay so here is my dilemma. I have written a BASH script that automatically restarts a tomcat on a given server. That part was simple enough. However, now I would like to not only restart the tomcat, but I would also like the script to check to make sure the Tomcat is running. The only problem is on some of the servers I look after, I have two tomcats running. Therefore, I need to be able to check to make sure that BOTH tomcats are running. (I am aware that if I restart one tomcat, the second tomcat wont necessarily be restarted)
Thank you all for taking the time to add your responses. I truly appreciate the effort on all of your parts.
Now, taking J-Man's and Chubler_XL's suggestions, I went ahead and changed:
if [ $tomcat_status = $TOMCAT_RUNNING ];
to
if [[ $tomcat_status = $TOMCAT_RUNNING ]]
Now the script is running! However, I guess there is still something wrong with either my $tomcat_status or $TOMCAT_RUNNING because the script is returning this:
[explorer@oso12d tools]$ ./mscc-test.sh
:::18080 :::8080
TOMCAT NOT RUNNING
SCRIPT COMPLETED
So obviously, the two are NOT equal. Any ideas of how I should modify the strings? If not, I might try some brainstorming and incorporate Ahamed101's suggestions.
Yes, this whole string matching thing with a CR imbedded is a bit flakey, my suggestion (post #7) should work. But you might be better off counting the lines found like suggested in post #3
For example if you come along later and indent your code to something like this: