A
A
Ao2019-05-21 12:37:13
linux
Ao, 2019-05-21 12:37:13

How to run a bash command as su in Go?

As in the program, execute the bash command: log in as su user ..?
cmd := exec.Command("mate-terminal","-e","su -c ls")
cmd.Run()
Opens terminal cono and waits for password...
How to programmatically enter password and then some commands ?
sudo password is not set, you cannot make changes to sudoers.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
alfss, 2019-05-21
@alfss

https://github.com/google/goexpect

S
Sergey Sashkin, 2019-05-22
@LexPex

I would do it with sudo

D
Denis, 2019-05-23
@Norkotik

echo "password" | sudo rm -rf /

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question