Search code examples
basherlangejabberderl

ERL: execute erl command from shell


so here is what I want - to execute the following mini script from bash shell:

mnesia:change_table_copy_type(schema, node(), disc_copies).

I am trying to find out the possibilities but can not find a clear answer. There is a "-noshell" option, or, "-oldshell" option but none of them say how to execute any command like the one above.

How do I do that?


Solution

  • You can use -noshell with -eval "mnesia:change_table_copy_type(schema, node(), disc_copies)" for this. You'll also have to pass -run init stop after that to make sure the Erlang VM stops after running the command, or the VM will keep running even after evaluating the -eval code.

    erl -noshell -eval "mnesia:change_table_copy_type(schema, node(), disc_copies)" -run init stop