As an example, the following code has 1 1 4
printed in the console. How do I capture that into a string variable?
run(pipeline(`echo 123`, `wc`))
As an example, the following code has 1 1 4
printed in the console. How do I capture that into a string variable?
run(pipeline(`echo 123`, `wc`))
s = readlines(pipeline(`echo 123`, `wc`))
or
s = readstring(pipeline(`echo 123`, `wc`))
There’s yet another solution in the docs:
read(pipeline(`echo 123`, `wc`), String)
This is equivalent to the readstring
example.
Cool!
And you could read lines asynchronously too!
julia> import Dates
julia> r = eachline(```
julia -e """
for i in 1:3
sleep(1)
println('*')
end"""
```);
julia> for i in r
println("$i $(Dates.now(Dates.UTC))")
end;
* 2018-10-11T10:43:28.4
* 2018-10-11T10:43:29.402
* 2018-10-11T10:43:30.404