# Variable bindings in IEx shell

**URL:** <https://forum.elixirforum.com/t/variable-bindings-in-iex-shell/41603>\
**Category:** Questions\
**Tags:** iex, development, binding\
**Created:** [August 11, 2021, 4:17pm UTC](https://forum.elixirforum.com/t/variable-bindings-in-iex-shell/41603 "2021-08-11T16:17:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nhpip](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nhpip/32/23811_2.png) [@nhpip](https://forum.elixirforum.com/u/nhpip)\
**Post date:** [August 11, 2021, 4:17pm UTC](https://forum.elixirforum.com/t/variable-bindings-in-iex-shell/41603/1 "2021-08-11T16:17:49Z")

</div>

First of all, don’t ask me why I want to do this 😀 It was an experiment I was trying. I since decided to do it a different way, but it got me curious.

In the shell (or any other process for that matter), given a string like `"time = System.os_time()"` I can evaluate it with `Code.eval_string("time = System.os_time()")` and get back `{1628697855326337000, [time: 1628697855326337000]}`.

Yes, I know I can copy/paste the thing too, but humor me.

Is there a way I can programmatically _inject_ the variable `time` into the shell’s variable bindings?

Basically do something like:

```elixir
iex(1)> MagicModule.magic_function("time = System.os_time()")
1628697855326337000
iex(2)> time
1628697855326337000
iex(3)>

```

---

<div class="post-metadata">

**Author:** ![nhpip](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nhpip/32/23811_2.png) [@nhpip](https://forum.elixirforum.com/u/nhpip)\
**Post date:** [August 11, 2021, 7:14pm UTC](https://forum.elixirforum.com/t/variable-bindings-in-iex-shell/41603/2 "2021-08-11T19:14:22Z")

</div>

I found a really hacky way to do it in the shell

```elixir
command = "foo = :ets.info(:pg2_table)"
send(self(), {:eval, Process.info(self())[:dictionary][:iex_server], command, %IEx.State{}})

```
