user10387080
user10387080

Reputation: 63

Capture the output of a process in Julia

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.

Upvotes: 5

Views: 769

Answers (1)

Simon Byrne
Simon Byrne

Reputation: 7864

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`)

Upvotes: 4

Related Questions