# Is it possible to pipe into \`julia\` command without it exiting immediately after

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-pipe-into-julia-command-without-it-exiting-immediately-after/116302>\
**Category:** General Usage\
**Tags:** question, cli\
**Created:** [June 27, 2024, 12:58pm UTC](https://discourse.julialang.org/t/is-it-possible-to-pipe-into-julia-command-without-it-exiting-immediately-after/116302 "2024-06-27T12:58:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![schlichtanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/schlichtanders/32/32145_2.png) [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Post date:** [June 27, 2024, 12:58pm UTC](https://discourse.julialang.org/t/is-it-possible-to-pipe-into-julia-command-without-it-exiting-immediately-after/116302/1 "2024-06-27T12:58:50Z")

</div>

hi there, I am wondering whether there is a flag which prevents julia from closing  
like

```bash
echo 'println("my initial command which I would like to show up")' | julia

```

should ideally result in something like

```julia
julia> println("my initial command which I would like to show up")
my initial command which I would like to show up
julia> 

```

---

<div class="post-metadata">

**Author:** ![HanD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hand/32/213908_2.png) [@HanD](https://discourse.julialang.org/u/HanD)\
**Post date:** [June 27, 2024, 1:03pm UTC](https://discourse.julialang.org/t/is-it-possible-to-pipe-into-julia-command-without-it-exiting-immediately-after/116302/2 "2024-06-27T13:03:04Z")

</div>

If you redirect stdin (that’s what the pipe does), then there isn’t much point in starting up the REPL, as it would also read from stdin, which is closed by this point.

However, you can run a script and then keep julia running, as follows:

```julia
$ julia --banner=no -ie 'println("my initial command which I would like to show up")'
my initial command which I would like to show up
julia> 

```

Note the `-i` switch, which forces Julia REPL into interactive mode.

HTH.

---

<div class="post-metadata">

**Author:** ![schlichtanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/schlichtanders/32/32145_2.png) [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Post date:** [June 27, 2024, 1:06pm UTC](https://discourse.julialang.org/t/is-it-possible-to-pipe-into-julia-command-without-it-exiting-immediately-after/116302/3 "2024-06-27T13:06:14Z")

</div>

Thank you very much. That is almost like I wished for - the julia command is not shown inside the REPL. But this should work indeed. Thank you so much!

---

<div class="post-metadata">

**Author:** ![HanD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hand/32/213908_2.png) [@HanD](https://discourse.julialang.org/u/HanD)\
**Post date:** [June 27, 2024, 1:11pm UTC](https://discourse.julialang.org/t/is-it-possible-to-pipe-into-julia-command-without-it-exiting-immediately-after/116302/4 "2024-06-27T13:11:39Z")

</div>

True, you have to work a bit harder for a local echo effect. E.g.,

```julia
$ julia --banner=no -ie 'macro echo(cmd) :(println("julia> ", $(QuoteNode(cmd))); $cmd; println()) end' -e '@echo println("my initial command which I would like to show up")'
julia> println("my initial command which I would like to show up")
my initial command which I would like to show up

julia> 

```
