5
votes

I can validate a config file with running the command

file:consult("settings.config").

Can I do this from a linux command? I know I can open the erl shell and run this command, but I want to do this with one shell command

1
You can use -eval option of erl.Xiao Jia
@XiaoJia how does that work? I tried various different combinations with -eval but it always gives a syntax error. The man page was not much help either.Eric
I was using this in my own project: erl -sname node1 -eval "test:foobar(123)." -noinput where test is a module for running different tests.Xiao Jia

1 Answers

9
votes

You could use an escript file to do this. Something like this:

validate.escript

#!/usr/bin/env escript
main([ConfigFile]) ->
    {ok, Terms} = file:consult(ConfigFile),
    io:format("~p~n",[Terms]).

Then you can invoke it from the command line:

./validate.escript path/to/file.config

Which will print the list of the terms of the config or throw an error if something went wrong.