escript works - !! yes

Mark Scandariato <>
Fri Jun 25 22:40:26 CEST 2004


(Doh! I didn't read the part where you added symlinks...)

Mark Scandariato wrote:
> Is ~joe/installed/... on your path too?
> 
> When I installed it, beam_evm wasn't moved from the build directory and 
> ERLANG_EARS was pointing to the build directory, too. (This didn't work 
> out too well for me: I built it in a solaris /tmp filesystem).
> 
> I had to manually copy beam_evm and mung the beginning of 
> ecc/elink/escript/ear with the correct path.
> 
> Once I did that everything worked.
> 
> Mark.
> 
> Joe Armstrong wrote:
> 
>>   Oh happy day
>>
>>   I found  to my *amazement* that  escript etc all seems  to get build
>> automatically in the R9C-2 build and everything works nicely. Thanks guys
>> great work.
>>
>>   This  seems  to  be   sparsely  documented  so  I've  appended  some
>> information to get you started at the end of this mail.
>>
>>   Personally  I very much  like Erlang  scripts, ideal  for automating
>> lots of trivial tasks.
>>
>>   Questions:
>>  
>>   1) Is the fact that this works a happy coincidence - I haven't dared
>> test the other stuff elink etc.
>>
>>   2) Does the fact  that this still work mean  that stand-alone Erlang
>> is still on the agenda?
>>
>> Cheers
>>
>> /Joe
>>
>>   If you want to try this at home do like this:
>>
>>   1) Build R9C-2
>>
>>   2) Put a couple of symlinks so that escript and beam_evm can be found
>>
>>     On my home machine I did this:
>>
>>     $ cd ~/bin
>>     $ ln -s /home/joe/installed/otp_src_R9C-2/erts/boot/src/escript
>>     $ ln -s 
>> /home/joe/installed/otp_src_R9C-2/bin/i686-pc-linux-gnu/beam_evm
>>
>>     (~/bin is in my path and ~joe/installed/... is where I built R9C)
>>
>>     After this erlang scripting sprang into life:
>>
>> Here are two example scripts
>>
>> --- fib1 ---
>>
>> #!/usr/bin/env escript
>>
>> -export([main/1]).
>>
>> main([X]) ->
>>     J = list_to_integer(X),
>>     N = fib(J),
>>     io:format("fib ~w = ~w~n",[J, N]).
>>
>> fib(0) -> 0;
>> fib(1) -> 1;
>> fib(N) ->
>>     fib(N-1) + fib(N-2).
>>
>> --- fib2 ----
>> #!/usr/bin/env escript
>>
>> -export([main/1]).
>>
>> -mode(compile).
>>
>> main([X]) ->
>>     J = list_to_integer(X),
>>     N = fib(J),
>>     io:format("fib ~w = ~w~n",[J, N]).
>>
>> fib(0) -> 0;
>> fib(1) -> 1;
>> fib(N) ->
>>     fib(N-1) + fib(N-2).
>>
>>
>> Just chmod them to executable and off you go.
>>
>> --------------------
>>
>> The timings are reasonably ok
>>
>>     $ ./fib1 1 (0.06 sec)
>>     $ ./fib2 1 (0.16 sec)
>>     $ ./fib1 25 (3.06 sec)
>>     $ ./fib2 25 (0.19 sec)
>>
>> fib2 has a compile annotation, so for lengthy calculations it is better
>> to incur the 0.14 sec compilation overhead.
>>
>>
> 
> 





More information about the erlang-questions mailing list