调用外部程序时如何静音或重定向STDOUT?

时间:2015-07-14 20:22:40

标签: julia

关注docs我这样做:

julia> run(`echo hello`)
hello

但实际上我不需要输出

julia> run(`echo hello`)

如何关闭它?我错过了什么?

内部process.jl 有一个名为 Process 的类型,但我现在没想到如何生成它。

更多见解here喜欢

julia> x = readall(`echo test`);

julia> x
"test\n"

1 个答案:

答案 0 :(得分:5)

在julia-0.4中,人们可以使用:

run(pipe(`echo test`, stdout="/dev/null", stderr="/dev/null"))

甚至更多跨平台

run(pipe(`echo test`, stdout=DevNull, stderr=DevNull))

NB pipe 未在julia-0.3

中定义
相关问题