Skip to content Skip to sidebar Skip to footer

Standard In Must Be A Tty Python Script Removing Sudo

I am trying to run the command 'sudo service awslogs start' from a python script. I cannot use 'sudo' so I change the command to 'su -c 'service awslogs start'' but that does

Solution 1:

sudo -S reads from stdin, see man sudo:

 -S, --stdin
     Write the prompt to the standard error and read the password from the
     standard input instead of using the terminal device.  The password must be
     followed by a newline character.

You can also change /etc/sudoer to allow your user to run the specific command without sudo.

Post a Comment for "Standard In Must Be A Tty Python Script Removing Sudo"