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.

link|improve this question
feedback

2 Answers

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.

link|improve this answer
1  
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
feedback

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

sudo -u db2inst1 "/home/db2inst1/sqllib/bin/db2 list database directory"
link|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
feedback

Your Answer

 
or
required, but never shown

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