如何从linux命令验证Erlang配置文件 [英] How do I validate an Erlang config file from a linux command

查看:98
本文介绍了如何从linux命令验证Erlang配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过运行命令

file:consult("settings.config").

我可以从linux命令执行此操作吗?我知道我可以打开erl shell并运行这个命令,但是我想用一个shell命令来执行此操作。

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

推荐答案

你可以使用escript文件来做到这一点。这样的:

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

validate.escript

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.

这篇关于如何从linux命令验证Erlang配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆