How do I validate an Erlang config file from a linux command

半城伤御伤魂 提交于 2019-12-23 10:49:14

问题


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 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.



来源:https://stackoverflow.com/questions/13423387/how-do-i-validate-an-erlang-config-file-from-a-linux-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!