我有一个文件xyz.erl,其中包含一个功能fun1。我想从linux脚本中调用它。
You can create escript from your file. Follow the instructions
In brief, you should add call instructions for the shell and erlang to the begginig of you file
#!/usr/bin/env escript
%% -*- erlang -*-
Then make file executable.
Then you can call erlang script as conventional script. Note that you still required Erlang runtime installed to execute script.
Erlang calls main/1
function of the script but you can pass function name as an argument to call it
main([Fun]) ->
FunAtom = list_to_atom(Fun),
?MODULE:FunAtom().
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.