I am trying to run the following command as
deploy from Java (the JVM is running as the user
sudo -u deploy /path/to/my/bash/script.sh PARAM1 PARAM2
My sudoers file has the following in it:
tomcat ALL=(deploy) NOPASSWD: /path/to/my/bash/script.sh *
But I get
sorry, you must have a tty to run sudo in my Java application. Therefore, I changed my invocation to be:
su --session-command="/path/to/my/bash/script.sh PARAM1 PARAM2" deploy
But now I get
standard in must be a tty in Java.
I have checked, and by doing the following I can see that
sudo doesn't prompt for a password but
[root@mybox bin]# sudo su tomcat [tomcat@mybox bin]$ sudo -u deploy /path/to/my/bash/script.sh PARAM1 PARAM2 output of script with PARAM1 PARAM2 [tomcat@mybox bin]$ su --session-command="/path/to/my/bash/script.sh PARAM1 PARAM2" deploy Password: su: incorrect password
sudoers is only for
sudo (hence the name). Is there another way of running the command as
deploy without a password prompt?
I am developing this on centos 6.3 but it will eventually be running on RHEL5.