小编ugi*_*ugi的帖子

continuously reading from exec.Cmd output

Guys I am trying pick new lines as they come from command output, but always I end up doing it synchronous way (I have to wait until script is finished). I tired to use fsnotify but it is working only with regular files, do you have any idea how it can be done ?

package main
import (
   "fmt"
   "os/exec"
   "bytes"
   "os"
)

func main() {
   cmd := exec.Command("scripts/long_script")
   output := new(bytes.Buffer)
   cmd.Stdout = output
   cmd.Stderr = output
   if err …
Run Code Online (Sandbox Code Playgroud)

stdout exec go

6
推荐指数
2
解决办法
3850
查看次数

标签 统计

exec ×1

go ×1

stdout ×1