Go语言调用其它程序并获得程序的输出
package main import ( "exec" // "os/exec" in go1 "fmt" ) func main(){ cmd := exec.Command("ls", "-l") buf, err := cmd.Output() fmt.Printf("%s\n%s",buf,err) }
Go语言调用其它程序并获得程序的输出
package main import ( "exec" // "os/exec" in go1 "fmt" ) func main(){ cmd := exec.Command("ls", "-l") buf, err := cmd.Output() fmt.Printf("%s\n%s",buf,err) }