Writing a script file to run in the Elixir console iex

Is it possible to write a script file that launches the Elixir console, and then compiling files and finally execute a function from a compiled file.

You can use a combination of iex -S and mix run to achieve what you are trying to do.

Let’s assume you have a script my-script.exs which contains the function call(s) that you want to execute on the compiled project.

iex -S 'mix run my-script.exs'

This will:

  • compile the project
  • run my-script.exs
  • drop you into iex

In that order.