parent
35d3e33070
commit
25cc645a48
|
@ -7,18 +7,18 @@
|
||||||
```go
|
```go
|
||||||
func MakeCmd(name string, arg ...string) *exec.Cmd {
|
func MakeCmd(name string, arg ...string) *exec.Cmd {
|
||||||
cmd := exec.Command(name, arg...)
|
cmd := exec.Command(name, arg...)
|
||||||
cmd.Env = append(cmd.Env, "USER=root")
|
cmd.Env = append(cmd.Env, os.Getenv("USER"))
|
||||||
cmd.Env = append(cmd.Env, "HOME=/home/root")
|
cmd.Env = append(cmd.Env, os.Getenv("HOME"))
|
||||||
cmd.Env = append(cmd.Env, "SHELL=/bin/sh")
|
cmd.Env = append(cmd.Env, os.Getenv("SHELL"))
|
||||||
cmd.Env = append(cmd.Env, "LOGNAME=root")
|
cmd.Env = append(cmd.Env, os.Getenv("LOGNAME"))
|
||||||
cmd.Env = append(cmd.Env, "PATH=/usr/local/bin:/usr/bin:/bin:/xt/scripts:/usr/local/sbin:/usr/sbin:/sbin:/xt/scripts")
|
cmd.Env = append(cmd.Env, os.Getenv("PATH"))
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cmd := MakeCmd("ls", "-l", "/")
|
cmd := MakeCmd("ls", "-l", "/")
|
||||||
output, _ := cmd.Output()
|
output, _ := cmd.Output()
|
||||||
fmt.Println(output)
|
fmt.Println(string(output))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue