Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 993
user10387080 Avatar asked Sep 19 '18 17:09

user10387080


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`)
like image 75
Simon Byrne Avatar answered Nov 09 '22 07:11

Simon Byrne