[erlang-questions] escript lives

Wayne Vucenic nightphotos@REDACTED
Sun Oct 15 21:33:33 CEST 2006


Hi Joe,

> 9) I start writing a book. <<The book please buy it>>.

I'm definitely looking forward to your new book.  Is it available yet?

> I would be grateful if you could let me know of any abnormalities that
> occur on other platforms - also if any windows users can run this I'd
> like to know what you think the best way to set this up is.

I'd like to get this working on Windows.  I decided to start with Mac OS X
as I expected that to be easier.  It wasn't hard to get it running, but I
did encounter several of those abnormalities:

I'm using Erlang R11B-1 on Mac OS X 10.4.7 with bash.

Mini:~/erlang/escript-4.0 wayne$ make
erlc escript.erl
make: *** No rule to make target `.beam', needed by `all'.  Stop.

as the erlc line above suggests, it actually did make the .beam file,
so I'm not sure why it thinks it needs to remake it but can't.

Mini:~/erlang/escript-4.0 wayne$ ls
Makefile        escript.erl     factorial       fibi            make_d_output
escript.beam    escript.html    fibc            history         mk_escript.sh
Mini:~/erlang/escript-4.0 wayne$ make
make: *** No rule to make target `.beam', needed by `all'.  Stop.

I've attached the output from "make -d", in case that sheds some light on this.

to work around this, I changed the Makefile line

all: ${BEAM_FILES} escript

to

all: escript.beam escript

this gets us past the .beam error, but now it has trouble making escript

Mini:~/erlang/escript-4.0 wayne$ make
./mk_escript.sh
make: ./mk_escript.sh: Command not found
make: *** [escript] Error 127

so I tried running mk_escript.sh directly, rather than with make

Mini:~/erlang/escript-4.0 wayne$ ./mk_escript.sh
: bad interpreter: No such file or directory

apparently it doesn't like the
#! /bin/bash
line, but that is the correct path to bash:

Mini:~/erlang/escript-4.0 wayne$ which bash
/bin/bash

so I removed the #! line and tried again

Mini:~/erlang/escript-4.0 wayne$ ./mk_escript.sh
: command not foundne 9:

(the above is not a typo, it really did say "foundne")

Now it apparently doesn't like that line 9 is blank, so I remove line 9

And it works:

Mini:~/erlang/escript-4.0 wayne$ ./mk_escript.sh
Mini:~/erlang/escript-4.0 wayne$ ./fibc 20
fib 20 = 10946

Let me know if you'd like me to try anything else on OS X.

It may be a little while before I have time to try this on Windows,
but when I do I'll post my results.

Wayne

---

Wayne Vucenic
No Bugs Software
Ruby, C#, and Erlang Agile Contract Programming in Silicon Valley


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


More information about the erlang-questions mailing list