In golang how can I write the stdout of an exec.Cmd to a file?

前端 未结 3 1393
梦谈多话
梦谈多话 2020-12-23 18:47

I am trying to run a shell command, capture stdout and write that output to a file. However, I seem to be missing a few steps, as the file I am trying to write is empty when

3条回答
  •  难免孤独
    2020-12-23 19:08

    You can also use:

    cmd.Stdout = os.Stdout
    

    which will redirect all cmd output to the OS' standard output.

提交回复
热议问题