I have made escript work again. 'twas lost - but now it is found.<br><br>Escript is a scripting interface to Erlang (see the history below)<br><br>Questions: This is tested only on Solaris and bash on R11B<br>                 
<br>The script bit needs some funny quoting that may not work on other systems.<br><br>I would be grateful if you could let me know of any abnormalities that occur on other platforms -<br>also if any windows users can run this I'd like to know what you think the best way to
<br>set this up is.<br><br>/Joe<br>1) 3-april-2001<br>   <br>   Joe Armstrong amd Robert Virding write escript.<br><br>   This is a pure erlang applications that allows erlang modules<br>   to be used as scripts:<br><br>   Example:
<br><br>    ./factorial 123<br>        factorial 123 = 1214630436702532967576624324188129585545<br>                        4217088483382315328918161829235892362167<br>                        6688311569606126402021707358352212940477
<br>                        8259109157041165147218602951990626164673<br>                        0733907419814952960000000000000000000000<br>                        000000<br><br>   The file factorial contains the following:
<br><br>        #!/usr/bin/env escript<br><br>        %%<br>        %% Usage:<br>        %%   factorial <Int><br>        <br>        %% Example of an interpreted script<br>        <br>        -export([main/1]).<br>        
<br>        main([X]) -><br>            case (catch list_to_integer(X)) of<br>            {'EXIT', _} -><br>                usage();<br>            J -><br>                N = fac(J),<br>                io:format("factorial ~w = ~w~n",[J, N])
<br>            end;<br>        main(_) -><br>            usage().<br>        <br>        usage() -><br>            io:format("Usage factorial <Int>~n").<br>        <br>        fac(0) -> 1;<br>        fac(N) ->
<br>            N * fac(N-1).<br>        <br>2) Escript has a rather long startup time<br><br>    time ./factorial 1  <br>    ...<br>    real    0m0.745s<br><br>   So I investigated why. The reason has to do with code loading ...
<br><br>3) I wrote SAE - stand-alone Erlang to solve this<br>   Then I implemented escript in SAE<br><br>   escript with SAE started very quickly (0.0N) seconds (ish)<br><br>4) Integration of SAE with the standard release was pretty difficult
<br>   (lots of modules have to be changed)<br><br>5) SAE never made it into the main release - but parts of it<br>   found there way into the bootstrap compiler.<br><br>6) escript ran for a while on SAE - but every new release
<br>   of ERlang required major effort to get it running again.<br><br>7) Escript stops working on the latest version of the system,<br>   because it now depends upon SAE which is broken.<br><br>   ...<br><br>8) I stop using escript and forget about it.
<br><br>9) I start writing a book. <<The book please buy it>>.<br><br>10) I want to describe loads of *useful* and little known tools.<br><br>11) I want make sure that escript works.<br><br>12) I google escript - since IƤve now *lost* the code 
<br><br>13) Google finds escript on MY web site (holy cows) - irony yes.<br><br>    This is the old "pure-erlang" version "pre SAE"<br><br>14) I compile this version<br><br>    It is broken.<br><br>    It depends upon a hacked version of erl_eval
<br>    this needs syncing with the latest version.<br><br>15) I look at the latest version of erl_eval<br><br>    I find this comment:<br><br>    %% Is used by standalone Erlang (escript).<br>        %% Also used by shell.erl
.<br>        -export([match_clause/4]).<br><br>    I suspect that erl_eval.erl is "up to date" with my hacked version,<br>    I check - it is.<br><br>16) I wonder.<br><br>    "is escript" in the *current* system?
<br><br>17) I check<br><br>    yes - it's in erts/boot/src/escript.erl<br><br>18) Does it work?<br><br>    no<br><br>19) I fix it<br>    <br>    It works<br><br>20) Is it installed by default?<br><br>    No<br><br>21) Is it documented
<br><br>    No<br><br>22) I fix it - fix the documentation<br>    and post to the Erlang list<br><br>/Joe<br><br>