[erlang-questions] Escript

Bengt Kleberg <>
Mon Apr 2 10:24:35 CEST 2007


On 2007-03-30 18:24, Julian Fondren wrote:
> On 3/30/07, Bengt Kleberg <> wrote:
>> it it possible to get the name of the script when using escript?
> 
> escript throws it away:
> 
>  start([_|X]) ->
>      X0 = map(fun(I) -> binary_to_list(I) end, X),
>      [_,File|Args] = X0,
>      ___,

1 this is not the escript in R11B-4, but yes the file name is removed 
from the arguments in R11B-4, too. that was why i wanted to get hold of 
it some other way.
2 the answer is: use init:get_plain_arguments(). like this:

#! /tmp/erlang/bin/escript

main(_) ->
	[Script_name|_T] = init:get_plain_arguments(),
	io:fwrite("~s~n", [Script_name]).

i would have prefered to have the script as the first argument (like in 
my patches) but this works.


bengt
-- 
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."



More information about the erlang-questions mailing list