10
votes

I'm struggling with a Mac OS X 10.5.8 that I've started using recently for development. I successfully installed tomcat and create launchd.conf for my environment variables.

I believe it works fine. Coz I can build a project with Netbeans using maven and cargo plugins successfully so i found online a script for start and stop the tomcat

#!/bin/bash

case $1 in
 start)
  sh /Library/apache-tomcat-6.0.20/bin/startup.sh
 ;; 
 stop)
  sh /Library/apache-tomcat-6.0.20/bin/shutdown.sh
 ;;
 restart)
  sh /Library/apache-tomcat-6.0.20/bin/shutdown.sh
  sh /Library/apache-tomcat-6.0.20/bin/startup.sh
 ;;
 *)
 echo "Usage :start|stop|restart"
 ;;
 esac
 exit 0

That script was created in nano in sudo sh but when i want to run it. is spit out this

sh: /usr/bin/tomcat: Permission denied

I've added chmod 755 *.sh and *.bat inside /Library/apache-tomcat-6.0.20/bin

Still access denied so what do I go around that? I have the admin privileges on the machine.

Thanks for reading

3

3 Answers

34
votes

Go to Tomcat bin directory and run the below command:

chmod +x *.sh

This worked for me.

5
votes

Where did you install the tomcat script to? I'd recommend you install it to /usr/bin. Once installed, make sure the permissions are correct (i.e. chmod 755 /usr/bin/tomcat). You can then confirm with ls -l /usr/bin/tomcat.

If you still get errors once the permissions on /usr/bin/tomcat are correct, then you can add the following two lines following the #!/bin/bash line.

set -x
set -v

With the above lines, bash will output additional information that will allow you to tell what's being executed and where the error is happening.

0
votes

1) Go to the tomcat directory, which preferably should be "/usr/local/folder-name"

2) Check for the permissions for the folder: ls -l

3) Change the permissions using: sudo chmod -R 755 folder-name

4) Change the owner to the current owner: sudo chown -R owner-name:group-name folder-name e.g sudo chown -R userName:admin folder-name

Try executing the script again and it should work.