Skip to content
Advertisement

“su ” fails with “standard in must be atty”

I researched this question and all answers suggest visudo to add: Defaults:user !requiretty

It does not work!

I have two Linux boxes (RedHat). I have a Java class which uses ProcessBuilder/Process to execute commands. The class runs under a system account. On both boxes, I run

su other-user -c 'some-command'

and provide the password for other-user in an input stream to the Process object.

On one box, the command succeeds and on the other I get the error above. The sudoers files on both machines did not have exclusions for requiretty (‘Defaults requiretty’ is set on both files). I tried adding the exclusion as suggested by the answers I found. I tried both the system user running the process and ‘other-user’…

Does not work.

What else can be the issue? Do I need to restart the system after adding the requiretty exceptoin(s)?

Advertisement

Answer

sudoers is for sudo rather than su so you should use sudo.

According to su manual:

-c, --command COMMAND

Specify a command that will be invoked by the shell using its -c.

The executed command will have no controlling terminal. This option cannot be used to execute interactive programs which need a controlling TTY.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement