Capture the output of a process in Julia

Viewed 533

I want to run a process and capture its output. According the documentation, method open(command, stdio=devnull; write::Bool = false, read::Bool = !write) should return a tuple (stream,process). But when running

typeof(open(`ls`))

the output is Base.Process. So only the process is returned, no stream.

Am I misunderstanding the documentation? How do I start a process and somehow capture its output.

1 Answers

That is an error in the documentation (the function was changed between 0.6 and 1.0, but the docs were not updated).

You can just call any "reading" function, such as read, eachline or readlines on the process, or even on the command itself, e.g.

readlines(open(`ls`))
readlines(`ls`)
Related