# Force interactive?

**URL:** https://discourse.julialang.org/t/force-interactive/9479
**Category:** General Usage
**Created:** [March 3, 2018, 9:45pm UTC](https://discourse.julialang.org/t/force-interactive/9479 "2018-03-03T21:45:31Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)
#### Post date: [March 3, 2018, 9:45pm UTC](https://discourse.julialang.org/t/force-interactive/9479/1 "2018-03-03T21:45:31Z")

</div>

dear julia experts—Is it possible to to invoke julia in batch but still receive the output as if the session was interactive REPL? maybe this could be done by tricking the session into thinking it is interactive, even though stdin comes from a file. for example, if my script ‘a.jl’ contains

```julia
x=[1,2,3]
x+22

```

I want to see (or construct) an output ‘a.log’ that looks like

```julia
julia> x=[1,2,3]
3-element Array{Int64,1}:
 1
 2
 3
julia> x+22
3-element Array{Int64,1}:
 23
 24
 25

```

I am thinking of using the Unix `expect` command, but this one has its own drawbacks, not the least of which is that julia prompts in boldface and I do not know how to turn this off. (`julia --color=off` does not turn off boldfacing afaics.)

(the use for this feature is to write tests for interactive sessions.)

advice appreciated.

regards,

/iaw

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [March 3, 2018, 9:50pm UTC](https://discourse.julialang.org/t/force-interactive/9479/2 "2018-03-03T21:50:22Z")

</div>

```julia
$ echo 1 + 2 | julia -i
3

```

---

<div class="post-metadata">

### Author: ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)
#### Post date: [March 4, 2018, 1:01am UTC](https://discourse.julialang.org/t/force-interactive/9479/3 "2018-03-04T01:01:17Z")

</div>

hi stefan—I had written a response why `julia -i < a.jl` does not work, but then decided to try, on the spur of the moment, `cat a.jl | julia -i`. The latter works, the former does not. I always thought the two were completely identical and indistinguishable from the perspective of the receiving program. (how does julia know the difference??) thanks. solves my problem.

/iaw

---

<div class="post-metadata">

### Author: ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)
#### Post date: [March 4, 2018, 2:51am UTC](https://discourse.julialang.org/t/force-interactive/9479/4 "2018-03-04T02:51:29Z")

</div>

almost. the trailing semi-colon that suppresses output seems to be ignored. can this be fixed?

```julia
$ echo "rand(2);" | julia -i
2-element Array{Float64,1}:
 0.60601
 0.685653

```

one way to avoid this is to replace any ‘;’ ending statements with

```julia
$ echo "rand(2);print()" | julia -i

```

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [March 4, 2018, 4:16am UTC](https://discourse.julialang.org/t/force-interactive/9479/5 "2018-03-04T04:16:04Z")

</div>

They’re distinguishable: pipe versus file. However they should both work so please do file an issue.

---

<div class="post-metadata">

### Author: ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)
#### Post date: [March 4, 2018, 6:11pm UTC](https://discourse.julialang.org/t/force-interactive/9479/6 "2018-03-04T18:11:57Z")

</div>

hi stefan—is it a buglet or intended behavior that a trailing semicolon does not suppress result output in “batch -i”?

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [March 4, 2018, 6:46pm UTC](https://discourse.julialang.org/t/force-interactive/9479/7 "2018-03-04T18:46:00Z")

</div>

Not sure. Might as well mention it in the same issue.

---

<div class="post-metadata">

### Author: ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)
#### Post date: [March 4, 2018, 9:29pm UTC](https://discourse.julialang.org/t/force-interactive/9479/8 "2018-03-04T21:29:15Z")

</div>

will do later today.
