[erlang-questions] Bug in escript when running under Windows?
Sat Jun 4 19:47:25 CEST 2011
I am new to Erlang. While learning it, I started writing Erlang scripts
running them with escript. One of the very nice feature of Erlang is that
it is cross platform. My escript files run fine in *nix boxes.
Unfortunately the implementation under Windows seems buggy: the ".exe"
extension must be placed after escript for the script to work.
That prevents using Windows PATHEXT capability which would allow launching
an Erlang escript file by simply giving its base name (like I can do it for
Python scripts on Windows for example).
On a Windows computer I added .erl to PATHEXT to get CMD to search for the
.erl file. I also associated the .erl file to the escript.exe file ( on
that computer it's c:/pg/erl/bin.escript.exe).
Here's a copy of my session, using the escript reference manual example:
usage: factorial integer
%% -*- erlang -*-
%%! -smp enable -sname factorial -mnesia debug verbose
N = list_to_integer(String),
F = fac(N),
io:format("factorial ~w = ~w\n", [N,F])
io:format("usage: factorial integer\n"),
fac(0) -> 1;
fac(N) -> N * fac(N-1).
C:\tmp>escript factorial 5
escript: Failed to open file: c:\pg\erl\bin\escript.escript
C:\tmp>escript.exe factorial.erl 5
factorial 5 = 120
As you can see, the first invocation, "factorial 5", is able to run the
script, but the arguments are not passed properly to the script.
The second invocation, "escript factorial 5" seems to indicate a bug in
escript as it is looking for the file c:\pg\erl\bin\escript.escript
The only way I can get it to work is to invoke it like this: "escript.exe
If there is one thing I like on Windows, it's the ability to invoke a script
by type the script name without the extension and the interpreter name.
Is this behaviour intentional or am I missing something?
-- Pierre Rouleau
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions