I am trying to make Julia work with an expect-like program. I do not want to adapt that program but have access to its source code.
The program assumes that (in this case) the julia REPL gives the answer plus a following new "julia> " prompt. My problem is that I do not get a match to the prompt.
I then tried to look what Julia is actually responding by piping its output to a file. And this varied from environment and terminal. Under Linux I got a lot of escape sequences, under Windows powershell a doubling of the input, then the response.
Speculating… Could this be only due to different terminals or could it be that Julia tries to do something smart/colorful with its output? Is there something like a switch to a simple/dumb mode, without escape sequences?
Thanks for any input!
The REPL (and its corresponding output, e.g. the
julia> prompt) is only used when running interactively. When you do e.g.
julia input_file.jl, the REPL doesn’t run at all and julia simply compiles & runs the code provided in the file.
Right, then the REPL is out.
I forgot to mention that the program launches Julia with the -i option.
Here is the output launching julia -i piped into Windows PS, , then 1+1:
./julia -i > toto.txt
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.6.2 (2021-07-14)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
I understand that the expect program has difficulties.
What to change?
You can turn off colouring when starting Julia. I do not remember exact option, but it’s easy to find, something like
julia -i --banner=no --color=no
might help a lot
Ok, the banner and the colors are gone, but not the escape sequences:
Changed the thread title to focus on escape sequences.
Is it in Windows? I’ve checked and there are no escape sequences in linux if I am doing
julia -i --banner=no --color=no > /tmp/toto.txt
> cat /tmp/toto.txt
julia> 1 + 1
EDITED: Oh, I see
> less /tmp/toto.txt
^Mjulia> ^M^M2 + 3^Mjulia> ^M2 + 3^M
^M^Mjulia> ^M^M^Mjulia> ^M^M
Hmm, that’s not how it should be.
You want to set the
TERM env variable to
dumb I think.
Thx a lot!
I had to use
ENV["TERM"] = "dumb";
as first command after launching
julia -iq > toto.txt
in order to suppress
Warning: Terminal not fully functional
plus following error messages.
Again an info which is not easy to spot in any usual Julia doc, try googling.
Pls. let me know if you are aware of an “official” documentation.
It is kind of a general thing, see Computer terminal - Wikipedia