Opening a prolog shell/repl process and sending strings to stdin and reading output doesn’t work. I don’t know what I am doing wrong but I tried a few methods and none of them seem to succeed. I just wanna run a long running prolog process and send some input prolog code, read the output, send some more, etc.
I would expect this to work but it does not:
julia> pb = IOBuffer();
julia> prolog_proc=open(`prolog`, pb;write=true)
Welcome to SWI-Prolog (threaded, 64 bits, version 9.0.4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
Process(`prolog`, ProcessRunning)
julia> prolog_proc
Process(`prolog`, ProcessRunning)
julia> prolog_proc.
cmd err
exitcode exitnotify
handle in
out termsignal
julia> prolog_proc.exitcode
-9223372036854775808
julia> write(prolog_proc, "consult(\"hhlighthouse\").")
18
julia> String(read(pb))
""
julia> read(prolog_proc)
UInt8[]
julia> String(read(prolog_proc))
""
I also tried this simpler version but no dice so far:
julia> p = open(`prolog`; read=true, write=true)
Welcome to SWI-Prolog (threaded, 64 bits, version 9.0.4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
Process(`prolog`, ProcessRunning)
julia> p
Process(`prolog`, ProcessRunning)
julia> p.in
Base.PipeEndpoint(RawFD(21) open, 0 bytes waiting)
julia> p.out
Base.PipeEndpoint(RawFD(22) open, 0 bytes waiting)
julia> write(p.in, "consult(\"hhlighthouse.pl\").")
27
julia> p.out
Base.PipeEndpoint(RawFD(22) open, 0 bytes waiting)
julia> p.in
Base.PipeEndpoint(RawFD(21) open, 0 bytes waiting)