# Julia output without escape sequences?

**URL:** <https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515>\
**Category:** General Usage\
**Created:** [July 29, 2021, 7:13pm UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515 "2021-07-29T19:13:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [July 29, 2021, 7:13pm UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/1 "2021-07-29T19:13:05Z")

</div>

I am trying to make Julia work with an [expect](https://likegeeks.com/expect-command/)-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!

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [July 29, 2021, 7:42pm UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/2 "2021-07-29T19:42:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [July 29, 2021, 8:30pm UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/3 "2021-07-29T20:30:06Z")

</div>

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`

```julia
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.6.2 (2021-07-14)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

e[?2004h
e[0Kjulia> 
e[7C
e[7C1+1
e[0Kjulia> 
e[7C1+1
e[10C
e[?2004l2

```

I understand that the expect program has difficulties.  
What to change?

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [July 29, 2021, 8:48pm UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/4 "2021-07-29T20:48:17Z")

</div>

You can turn off colouring when starting Julia. I do not remember exact option, but it’s easy to find, something like `--nocolor`.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [July 29, 2021, 8:49pm UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/5 "2021-07-29T20:49:40Z")

</div>

looks like:

```julia
julia -i --banner=no --color=no

```

might help a lot

---

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [July 29, 2021, 9:11pm UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/6 "2021-07-29T21:11:20Z")

</div>

Ok, the banner and the colors are gone, but not the escape sequences:

```julia
e[?2004h
e[0Kjulia> 
e[7C
e[7C1+1
e[0Kjulia> 
e[7C1+1
e[10C
e[?2004l2

e[0K
e[0Kjulia> 
e[7C
e[7Ce[?2004h
e[0Kjulia> 
e[7C
e[7Cexit()
e[0Kjulia> 
e[7Cexit()
e[13C
e[?2004l

```

---

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [July 30, 2021, 6:17am UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/7 "2021-07-30T06:17:44Z")

</div>

Changed the thread title to focus on escape sequences.

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [July 30, 2021, 7:14am UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/8 "2021-07-30T07:14:02Z")

</div>

Is it in Windows? I’ve checked and there are no escape sequences in linux if I am doing

```julia
julia -i --banner=no --color=no > /tmp/toto.txt

```

```bash
> cat /tmp/toto.txt
julia> 1 + 1
2

```

EDITED: Oh, I see

```julia
> less /tmp/toto.txt
^Mjulia> ^M^M2 + 3^Mjulia> ^M2 + 3^M
5

^M^Mjulia> ^M^M^Mjulia> ^M^M

```

Hmm, that’s not how it should be.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 2, 2021, 3:44pm UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/9 "2021-08-02T15:44:32Z")

</div>

You want to set the `TERM` env variable to `dumb` I think.

```julia
TERM=dumb julia

```

---

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [August 2, 2021, 8:32pm UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/10 "2021-08-02T20:32:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 3, 2021, 11:09am UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515/11 "2021-08-03T11:09:28Z")

</div>

It is kind of a general thing, see [Computer terminal - Wikipedia](https://en.wikipedia.org/wiki/Computer_terminal#Dumb_terminals)
