package main import ( "os" "os/exec" ) func main() { f,_ := os.Create("1.txt") cmd := exec.Command("su","-","user00","-c","cd /tmp;nohup sh 1.sh &") cmd.Stdout = os.Stdout cmd.Stderr = f cmd.Run() }原文链接:https://www.f2er.com/go/189883.html
package main import ( "os" "os/exec" ) func main() { f,_ := os.Create("1.txt") cmd := exec.Command("su","-","user00","-c","cd /tmp;nohup sh 1.sh &") cmd.Stdout = os.Stdout cmd.Stderr = f cmd.Run() }原文链接:https://www.f2er.com/go/189883.html