在 Julia 中捕获进程的输出
Capture the output of a process in Julia
我想要 运行 一个进程并捕获它的输出。根据 the documentation,方法 open(command, stdio=devnull; write::Bool = false, read::Bool = !write)
应该 return 一个元组 (stream,process)
。但是当运行ning
typeof(open(`ls`))
输出是Base.Process
。所以只有进程 returned,没有流。
我是不是误解了文档?我如何启动进程并以某种方式捕获其输出。
那是一个error in the documentation(函数在 0.6 和 1.0 之间发生了变化,但文档没有更新)。
您可以在进程上调用任何 "reading" 函数,例如 read
、eachline
或 readlines
,甚至可以在命令本身上调用,例如
readlines(open(`ls`))
readlines(`ls`)
我想要 运行 一个进程并捕获它的输出。根据 the documentation,方法 open(command, stdio=devnull; write::Bool = false, read::Bool = !write)
应该 return 一个元组 (stream,process)
。但是当运行ning
typeof(open(`ls`))
输出是Base.Process
。所以只有进程 returned,没有流。
我是不是误解了文档?我如何启动进程并以某种方式捕获其输出。
那是一个error in the documentation(函数在 0.6 和 1.0 之间发生了变化,但文档没有更新)。
您可以在进程上调用任何 "reading" 函数,例如 read
、eachline
或 readlines
,甚至可以在命令本身上调用,例如
readlines(open(`ls`))
readlines(`ls`)