Running a command a different user using `su` gives “standard in must be a tty”

automated-testingsu

I am using STAF to automate db2 interface testing with our product. I am able to run the command using su - db2inst1 -c "/home/db2inst1/sqllib/bin/db2 list database directory" but when I try the same command with the staf interface I am getting the error:

standard in must be a tty

I commented the "Defaults requiretty" in /etc/sudoers, but still have the same issue.

Best Answer

Drop the lone dash (-) in your su command. That triggers su to ask for a login shell. A tty might be required by some program in your login chain.