~/erlang_programs$ erlc a.erl
a.erl:2: Warning: export_all flag enabled - all functions will be exported
~/erlang_programs$ ls a.*
a.beam a.erl
~/erlang_programs$ erl -noshell -s a go -s init stop
hello
Now, if your module is actually in a different directory than the directory where you are issuing the erl command, then you can use a flag to specify the path to the .beam file:
~/erlang_programs$ cd ..
~$
~$ erl -noshell -s a go -s init stop -pa ./erlang_programs
hello
Note that the module you posted is named helloworld and the function in that module is named start , yet your erl command is:
erl -noshell -s top start -s init stop
That erl command requires a module named top to be present in the current directory.
2条答案
按热度按时间wyyhbhjk1#
只需使用
-import
指令将其导入即可。下面是导入helloworld
模块的示例:如果你把上面的代码保存在
top.erl
中,你就可以在shell中这样使用它:3lxsmp7m2#
I'm able to run it from shell as you have mentioned above but not able to run by using this command:
even after creating ".beam" files.
Now, if your module is actually in a different directory than the directory where you are issuing the erl command, then you can use a flag to specify the path to the
.beam
file:Note that the module you posted is named
helloworld
and the function in that module is namedstart
, yet your erl command is:That erl command requires a module named
top
to be present in the current directory.