透明思考


Transparent Thoughts


Escript- Running Erlang As Scripts

(以下摘抄自Programming Erlang第六章)

Using escript you can run your programs directly as scripts—there’s no need to compile them first.

Warning:escript is included in Erlang versionsR11B-4 and onward. If you havean earlier version of Erlang, then you should upgrade to the latestversion of Erlang.

To run hello as an escript, we create the following file:

#!/usr/bin/env escriptmain(_) -gt;nbsp;io:format(“Hello world\n” ).

On a Unix system,we can run this immediately and without compilation as follows:

$ chmod u+x hello$ ./helloHello world$