# REPL in the middle of a script

**URL:** https://discourse.julialang.org/t/repl-in-the-middle-of-a-script/62126
**Category:** New to Julia
**Created:** [May 31, 2021, 10:56am UTC](https://discourse.julialang.org/t/repl-in-the-middle-of-a-script/62126 "2021-05-31T10:56:15Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![minshall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/minshall/32/25691_2.png) [@minshall](https://discourse.julialang.org/u/minshall)
#### Post date: [May 31, 2021, 10:56am UTC](https://discourse.julialang.org/t/repl-in-the-middle-of-a-script/62126/1 "2021-05-31T10:56:15Z")

</div>

hi. i am writing a script that, during processing, may occasionally want to drop into REPL (using [some custom REPL](https://discourse.julialang.org/t/programmatic-access-to-repl-like-pkg-debugger-etc/61723/3)), then, on a `Ctrl-d`, say, go back to processing. during any execution, the script may want to invoke its REPL zero, one, or more times.

i’m not sure how to accomplish this. iiuc, the `-i` option runs only after the script exits. also, i would rather have the script, when running, have `isinteractive()` return `false` (as i use its value for adapting the script’s interactions with the user), but the `-i` option has it return `true`.

is this possible? thanks!

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [May 31, 2021, 12:03pm UTC](https://discourse.julialang.org/t/repl-in-the-middle-of-a-script/62126/2 "2021-05-31T12:03:17Z")

</div>

You may use Infiltrator.jl:

> **[GitHub - JuliaDebug/Infiltrator.jl: No-overhead breakpoints in Julia](https://github.com/JuliaDebug/Infiltrator.jl)**
>
> No-overhead breakpoints in Julia. Contribute to JuliaDebug/Infiltrator.jl development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![minshall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/minshall/32/25691_2.png) [@minshall](https://discourse.julialang.org/u/minshall)
#### Post date: [June 1, 2021, 2:29am UTC](https://discourse.julialang.org/t/repl-in-the-middle-of-a-script/62126/3 "2021-06-01T02:29:21Z")

</div>

@heliosdrm thanks! i’ll have to look and see how to meld that with `ReplMaker`.

---

<div class="post-metadata">

### Author: ![minshall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/minshall/32/25691_2.png) [@minshall](https://discourse.julialang.org/u/minshall)
#### Post date: [June 6, 2021, 5:59pm UTC](https://discourse.julialang.org/t/repl-in-the-middle-of-a-script/62126/4 "2021-06-06T17:59:32Z")

</div>

@heliosdrm again, thanks. however, a trivial test generates a complaint from Infiltrator.jl:

```julia
bash apollo2 (main): {49701} cat x.jl
using Infiltrator

@infiltrate
bash apollo2 (main): {49702} julia x.jl
Infiltrator.jl needs a proper Julia REPL.
bash apollo2 (main): {49703}

```

my vague sense is that if you are executing a script, the Julia runtime doesn’t set things up for a REPL. i guess then my question is, is there some way to cause things to be set so at REPL can run, either as the script is being initialized, or when the script gets to points where it decides to interact, via a REPL, with its user.

cheers, Greg

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [June 6, 2021, 6:56pm UTC](https://discourse.julialang.org/t/repl-in-the-middle-of-a-script/62126/5 "2021-06-06T18:56:15Z")

</div>

I think you should be able to do `bash apollo2 (main): {49702} julia`, and then

```julia
include("x.jl")

```

and `Infiltrator` should give you control.

---

<div class="post-metadata">

### Author: ![minshall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/minshall/32/25691_2.png) [@minshall](https://discourse.julialang.org/u/minshall)
#### Post date: [June 7, 2021, 1:36am UTC](https://discourse.julialang.org/t/repl-in-the-middle-of-a-script/62126/6 "2021-06-07T01:36:50Z")

</div>

hi, @PetrKryslUCSD – yes, that works (though with a slightly amended source file – below). my hope, though, is to have a “standard shell command”, command line arguments, etc. so, i’m hoping to find a way to do that.

```julia
using Infiltrator

function foo()
    @infiltrate
end

foo()

```

(Infiltrator doesn’t seem to work so well at the top level.)
