自分自身のファイル名を知る方法
Posted feedbacks - Erlang
escript で。
1 2 | #!/usr/bin/env escript
main(_) -> io:fwrite("~s~n", [escript:script_name()]).
|
もっといい方法がありそう。。。 実行結果 $erl -noshell -run my bin -s init stop my.beam $erl -noshell -run my src -s init stop my.erl
1 2 3 4 5 6 | -module(my).
-export([src/0,bin/0]).
src()->
io:format("~s~n",[filename:basename(?FILE)]).
bin()->
io:format("~s~n",[filename:basename(code:which(?MODULE))]).
|


ところてん
#5728()
Rating1/1=1.00
see: #3301
[ reply ]