Hi
I’m trying to set-up communication with an interactive program.
I’ll use bc for my example.
I quickly found that this works:
julia> (p, process)=open(`bc`, "w", STDOUT)
(Pipe(open => closed, 0 bytes waiting),Process(`bc`, ProcessRunning))
julia> write(p, "2*3\n")
6
4
However, what I can’t figure out is what to substitute for STDOUT.
open(cmds::Base.AbstractCmd, mode::AbstractString, other::Union{Base.FileRedirect,IO,RawFD})
I thought the most obvious thing was to use an IOBuffer so that the process would simple write into the buffer and then of course I could read from it, but that is not type compatible.
julia> s=IOBuffer(100)
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=100, ptr=1, mark=-1)
julia> (p, process)=open(`bc`, "w", s)
ERROR: MethodError: no method matching uvtype(::Base.AbstractIOBuffer{Array{UInt8,1}})
Closest candidates are:
uvtype(::RawFD) at process.jl:158
uvtype(::Base.DevNullStream) at process.jl:151
uvtype(::Base.Filesystem.File) at filesystem.jl:70
ok, no problem, I just need to turn by IOBuffer into a File. And that’s where i get stuck.
Any hints ?
Thank you!