Three Ways How To Run Elixir Script — Tentamen Software Testing Blog

Image for post
Image for post
Project created with Elixir mix command



For what purpose you can use iex shell? I use it in my Phoenix application to experiment with the codebase. For example, when I need quickly to update a user record subscription expiration date. Or when I want to see the actual response when I try to find none existent Braintree transaction.


elixir get_todays_stock_values.ex

What happens under the hood is this:

  1. BEAM instance is started, the script is compiled, and the .beam file is loaded into the memory. .beam file is not created on disk.
  2. Everything outside the module definition is interpreted. This is how to bootstraps script execution
  3. after the script is done, BEAM is stopped.

To distinguish such a script from Elixir code, we use exs extension. Elixir Test Framework is interpreting test scripts, and you will learn that test scripts have exs extension.

Here is a script example:

You can run it with:

elixir script_example.exs

Or with

elixir --no-halt script_example.exs

if your script is some kind of server. In this case, the BEAM instance will not be halted after script execution.


mix new my_first_elixir_project

For now, just remember that this creates a folder with several Elixir files. For example, it creates the first test in the test folder.

You can run mix generated module with this:

mix run -e "IO.puts(MyFirstElixirProject.hello())"


  1. iex
  2. elixir
  3. mix

Originally published at on November 19, 2020.

Written by

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store