Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
If you remove the dash, you'll need to make sure to set the DB2-related environment variables for that command. – justarobert Apr 15 '11 at 11:54

/etc/sudoers does not govern the behavior of su. You want something like

sudo -u db2inst1 "/home/db2inst1/sqllib/bin/db2 list database directory"
share|improve this answer
Actually sudo doesnot work with STAF framework, so I need to execute it with su - useranem -c Command only. – Sanjeev Apr 15 '11 at 10:07
su doesn't normally have the restriction of needing to run in a tty; it's used all the time in init scripts, for example. Could this be a limitation of the db2 binary or of staf? What happens when you put the command into a shell script and run it? – justarobert Apr 15 '11 at 10:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.