# Start repl from non-interactive session

**URL:** <https://discourse.julialang.org/t/start-repl-from-non-interactive-session/3532>\
**Category:** General Usage\
**Tags:** question, repl\
**Created:** [May 5, 2017, 11:34am UTC](https://discourse.julialang.org/t/start-repl-from-non-interactive-session/3532 "2017-05-05T11:34:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nico202](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nico202/32/1009_2.png) [@nico202](https://discourse.julialang.org/u/nico202)\
**Post date:** [May 5, 2017, 11:34am UTC](https://discourse.julialang.org/t/start-repl-from-non-interactive-session/3532/1 "2017-05-05T11:34:04Z")

</div>

Hi, I cannot find this question elsewhere. I want to be able to start the REPL from a julia script if a certain condition occurs (for debugging purpose/fixing bugs live) without having to include(“program.jl”) directly from the REPL.

Something like importing Base.REPL, but don’t know which function to call to set it up.

Thanks, Nicolò

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [May 6, 2017, 2:33am UTC](https://discourse.julialang.org/t/start-repl-from-non-interactive-session/3532/2 "2017-05-06T02:33:03Z")

</div>

Basic example:

```julia
using Base: REPL, Terminals

term = Base.Terminals.TTYTerminal(get(ENV, "TERM", @static is_windows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
active_repl = REPL.LineEditREPL(term, true)
REPL.run_repl(active_repl, backend->(global active_repl_backend = backend))

```

See `_start` in `base/client.jl` for how to set up history (and other options).

---

<div class="post-metadata">

**Author:** ![nico202](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nico202/32/1009_2.png) [@nico202](https://discourse.julialang.org/u/nico202)\
**Post date:** [May 6, 2017, 4:24pm UTC](https://discourse.julialang.org/t/start-repl-from-non-interactive-session/3532/3 "2017-05-06T16:24:04Z")

</div>

Cool, many thanks!  
How to “continue” (close it without exiting the program?). It works with CTRL-d but which is the command it’s sending?

Thanks again, Nicolò

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [May 6, 2017, 4:34pm UTC](https://discourse.julialang.org/t/start-repl-from-non-interactive-session/3532/4 "2017-05-06T16:34:14Z")

</div>

You’d probably have to throw an error to the backend task. I’m not sure how to do that off-hand, but I’ll take a look when I get a chance (if no one else has an answer).

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [May 23, 2017, 4:01pm UTC](https://discourse.julialang.org/t/start-repl-from-non-interactive-session/3532/5 "2017-05-23T16:01:56Z")

</div>

doesn’t just `exit()` work?

---

<div class="post-metadata">

**Author:** ![nico202](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nico202/32/1009_2.png) [@nico202](https://discourse.julialang.org/u/nico202)\
**Post date:** [May 23, 2017, 4:09pm UTC](https://discourse.julialang.org/t/start-repl-from-non-interactive-session/3532/6 "2017-05-23T16:09:31Z")

</div>

no, because it will exit everything.  
ie. if you have  
#snippet from ihnorton  
println(“running this line”)

Pressing ctrl-D will show “running this line”, while exit() will not
