2020
12-23
12-23
golang执行命令操作 exec.Command
我就废话不多说了,大家还是直接看代码吧~cmd:=exec.Command("cmd")in:=bytes.NewBuffer(nil)cmd.Stdin=in//绑定输入varoutbytes.Buffercmd.Stdout=&out//绑定输出gofunc(){in.WriteString("nodeE:/design/test.js\n")//写入你的命令,可以有多行,"\n"表示回车}()err=cmd.Start()iferr!=nil{log.Fatal(err)}log.Println(cmd.Args)err=cmd.Wait()iferr!=nil{log.Printf("Commandfinishe...
继续阅读 >