# Call functions from shell using scripts

**URL:** <https://forum.elixirforum.com/t/call-functions-from-shell-using-scripts/34657>\
**Category:** Questions\
**Tags:** script, learning-elixir, powershell\
**Created:** [September 30, 2020, 12:37pm UTC](https://forum.elixirforum.com/t/call-functions-from-shell-using-scripts/34657 "2020-09-30T12:37:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torounia](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/torounia/32/23403_2.png) [@Torounia](https://forum.elixirforum.com/u/Torounia)\
**Post date:** [September 30, 2020, 12:37pm UTC](https://forum.elixirforum.com/t/call-functions-from-shell-using-scripts/34657/1 "2020-09-30T12:37:45Z")

</div>

Hi there,

I have a script named ListModules.exs that contains the below,

```elixir
defmodule ListModule do
  def sum([]), do: 0

  def sum([head | tail]) do
    head + sum(tail)
  end
end

```

How can I run the above from a windows shell and call the function sum()?

I tried to run `elixir -r ListModule.exs -e "ListModule.sum([])"` and I don’t get back anything. If I try to parse the list [1,2,3] to the list argument it gives me the following error: `"!VAR:" was unexpected at this time.`

Any help is welcome.

Regards,

---

<div class="post-metadata">

**Author:** ![Nicd](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nicd/32/2357_2.png) [@Nicd](https://forum.elixirforum.com/u/Nicd)\
**Post date:** [September 30, 2020, 1:18pm UTC](https://forum.elixirforum.com/t/call-functions-from-shell-using-scripts/34657/2 "2020-09-30T13:18:30Z")

</div>

Try outputting the result, otherwise it is just thrown away:

```elixir
➜ ~ elixir -r ListModule.exs -e "ListModule.sum([])"
➜ ~ elixir -r ListModule.exs -e "IO.inspect(ListModule.sum([]))"
0
➜ ~ elixir -r ListModule.exs -e "IO.inspect(ListModule.sum([1, 2, 3]))"
6

```

---

<div class="post-metadata">

**Author:** ![Torounia](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/torounia/32/23403_2.png) [@Torounia](https://forum.elixirforum.com/u/Torounia)\
**Post date:** [September 30, 2020, 7:32pm UTC](https://forum.elixirforum.com/t/call-functions-from-shell-using-scripts/34657/3 "2020-09-30T19:32:01Z")

</div>

Thank you Nicd!
