my programs purpose is to do some tasks and then sudosh as a user all the way at the end.
However when running this with Go I get the sudosh: couldn't get your controlling terminal.
Is this because sudosh is looking for a controlling terminal and can't find it? Is this possible to do with Go? I am converting a Python script over to this Go program and it worked fine in Python.
import (
"github.com/codeskyblue/go-sh"
"fmt"
"os"
)
c, _ := sh.Command("sudo", "sudosh", "bob").Output()
fmt.Println(c)
os.Exit(0)
sudosh: couldn't get your controlling terminal.
The Fix
import "os/exec"
func sudosh(name string) {
c := exec.Command("/bin/sh", "-c", "sudo /path/to/sudosh " + name)
c.Stdin = os.Stdin
c.Stderr = os.Stderr
c.Stdout = os.Stdout
o := c.Run()
o=o
}