0

I use Tomcat 9.0.41 which comes bundled with an application. After the application was installed I try to run Tomcat by using the provided scripts. But those scripts throw a lot of errors like this:

./catalina.sh: 281: [[: not found
./catalina.sh: 286: [[: not found
./catalina.sh: 291: [[: not found
./catalina.sh: 295: [[: not found
./catalina.sh: 300: [[: not found
./catalina.sh: 305: [[: not found
./catalina.sh: 310: [[: not found

The line with the if is line 281:

#!/bin/sh
...
if [[ -n $SERVER_CERT_PATH && $SERVER_CERT_PATH != "" ]]; then
  SRV_KS_PATH=$SERVER_CERT_PATH
fi

I checked several posts like this about scripts and the behaviour of [[ but haven't found a reason why these messages appear. The environment I run all this in is Ubuntu 20.04, the test utility exists.

When I force to use bash by calling bash catalina.sh I don't see any errors. But for nested scripts like startup.sh which inside calls catalina.sh this doesn't work.

Is there a way to fix this ? I don't want to edit the scripts if possible. Perhaps I need to change some OS setting ? (which would make this more of a UNIX SE or askubuntu question)

Marged
  • 10,577
  • 10
  • 57
  • 99
  • 1
    The standard [`catalina.sh`](https://github.com/apache/tomcat/blob/master/bin/catalina.sh) script is POSIX compliant and does not contain those [_bashisms_](https://unix.stackexchange.com/q/306111/381289). How did you install Tomcat? – Piotr P. Karwasz Mar 19 '21 at 13:00
  • 1
    The scripts need to be modified to use only `sh` syntax, like @PiotrP.Karwasz. You could try just changing the first line with `#!/bin/bash`. But remember that using non-standard scripts expose you for the future, if you patch or upgrade your tomcat (and you should!). – Nic3500 Mar 19 '21 at 14:50
  • @Nic3500 We receive the script bundled with an application sold by Microfocus. Whenever they update I would have to apply the same changes. – Marged Mar 19 '21 at 20:51
  • If the application was sold to your company with a failing start script, I would call up support and demand something that works. If they cannot fix it quickly, I would reconsider having future business with these guys, their QA is seriously lacking. – Nic3500 Mar 19 '21 at 22:27
  • @Nic3500 We already created a ticket because of this. And asked why they changed that script. Btw: it works quite fine on CentOS, RHEL and Amazon Linux which they officially support – Marged Mar 20 '21 at 15:47

0 Answers0