Mailinglist Archive: opensuse (783 mails)

< Previous Next >
Re: [opensuse] Run command as another user
Why is this discussion still going on, when I posted a method that has
worked for me for years? Just create a directory where sudo can be used
to run scripts, without requiring a password.

Look back to when I posted it on Sept 28.

On 10/06/2017 06:54 AM, Richmond wrote:
I am pretty sure I have done this by having an entry in the sudoers file
saying allow this command by this user without a password.

I haven't read all the replies so excuse repetition, and if you can't
change the sudoers file then this is no use.

Paul Groves wrote:
Hi,

I need to be able to run a command as another user.

I have worked out that I can run the following from one user to
execute a command as the other (bob).

su - bob -c command
prompt for password
enter password

command runs as bob

but, how can I run this on one line for use in a script? (so that I am
not prompted for a password).
something like; su - bob -c command -p bobspassword

The user executing the script is not a sudoer so I cannot use; echo
bobspassword | sudo -S -u bob command

thanks
Paul




--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
List Navigation
References