I inherited this. Long story short I have an XML file that is calling a shell to run some commands. Everything I have tried has failed at the second su in the script. Here are some of the failure messages:sudo: no tty present and no askpass program specifiedOrsu: must be run from a terminalOrusage: sudo [-D level] -h | -K | -k | -V blah blah blahHere is snippet of my script. It only fails at the second su attempt:  <script language=shell><![CDATA[                  echo Doing some stuff                  sudo -u adminuser /path/to/a/script/script                  echo Emailing this stuff...              su emailuser -c mutt -e 'set content_type=text/html' -s 'Your stuff is ready' -- ${WHOEVER_PARAM_RECIPIENT} < /tmp/emailingstuff.html                ]]></script>I've played around with permissions so much that I forgot where I was with them. Here they are currently in sudoers:# See the man page for details on how to write a sudoers fileDefaults:emailuser !authenticateadminuser ALL=NOPASSWD: /bin/su - emailuseradminuser ALL=NOPASSWD: /bin/su emailuseradminuser ALL=NOPASSWD: /usr/bin/sudo su emailuser# Host alias specification# User alias specification# Cmnd alias specification# User privilege specificationroot    ALL=(ALL:ALL) ALL# Members of the admin group may gain root privileges%admin ALL=(ALL) ALL# Allow members of group sudo to execute any command%sudo   ALL=(ALL:ALL) ALL# See sudoers(5) for more information on #include directives:#includedir /etc/sudoers.d
Switch users with sudo or su in a shell script
bash;shell script;sudo;su