calling Elixir method using shell script

Lahiru
defmodule MyModule do
   def print do
        IO.puts "hi all"
    end
end

This is my Elixir module contained in MyModule.erl

iex MyModule.erl
MyModule.print

I was trying to run the elixir method using a shell script. It compiles the file but

iex MyModule.erl

is not running. I think it's because the first command goes to Erlang virtual machine. How to call this method?

José Valim

Elixir files generally have .ex extension. And if you are not planning to compile it, we recommend using the .exs file. We cover those differences in our getting started guide.

Assuming you write the file above to "mod.exs", one of the ways to achieve what you want is:

elixir -r mod.exs -e "MyModule.print"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

calling Elixir method using shell script

From Dev

Calling function in Shell script

From Dev

Calling another program in a shell script and using the returned data

From Dev

Calling a shell script using subprocess doesn't run all the commands in shell script

From Dev

Calling Shell Script with JavaScript for Automation

From Dev

Calling function in bash/Shell Script

From Dev

Calling .jar from shell script

From Dev

Calling function in bash/Shell Script

From Dev

Calling Shell Script with JavaScript for Automation

From Dev

Calling a shell script from python

From Dev

Calling a shell script using SSH exec channel, but it ignores calls to other shell scripts

From Dev

Generic method to catch error return using expect script (shell)

From Dev

Calling groovy method from script

From Dev

Calling groovy method from script

From Dev

Calling Method using reflection

From Dev

Calling a method using strings

From Dev

Check whether any value is zero using jq and return 0 to the calling shell script

From Dev

Calling Rscript from linux shell script

From Dev

Calling a simple shell script from java is not working

From Dev

terminate a running program in the calling shell script

From Dev

Linux shell script for calling Java program with arguments

From Dev

Calling shell script from C++

From Dev

Calling python function from shell script

From Dev

Shell script calling rows from text document

From Dev

Command not found while calling function in shell script

From Dev

How to reload .bashrc in the shell calling a script

From Dev

Change directory from python script for calling shell

From Dev

Using arrays in a shell script

From Dev

using mkfifo in a shell script

Related Related

HotTag

Archive