[erlang-questions] escript and archives

Angel J. Alvarez Miguel <>
Tue Oct 18 10:47:31 CEST 2011


Hi,

I want to packe some beams on a .ez archive and then insert the escript header 
to get a selfcontaines script ala rebar..

i made a script witth a zip archive the usual way..

	Files = filelib:fold_files("./ebin",
				".*",
				true,
				fun(Path, Acc) ->
					io:format("Procesando fichero ~s \n",[Path]),
					{ok, Bin} = file:read_file(Path),
					[{Path, Bin}|Acc] end,
				[]),
	{ok, {"mem", ZipBin}} = zip:create("mem", Files, [memory]),
	Script = <<"#!/usr/bin/env escript\n%%! -noshell -noinput\n", 
ZipBin/binary>>,

	ok = file:write_file("walker", Script),
	os:cmd("chmod u+x walker"),


i have my ebin dir with my two test files, the getopt.erl from jcomellas git 
and a simple walker.erl file:

-module(walker).

-export([main/1]).

main([String]) ->
	io:format("Up and running!! mayormente... (args:~s )\n",[String]),
	halt(0);

main(_) -> 
  io:format("Uso: ~s <args> \n",[escript:script_name()]),
  halt(1).


but then escript doesnt find the walker file:
 
./walker
escript: exception error: undefined function walker:main/1
  in function  escript:run/2
  in call from escript:start/1
  in call from init:start_it/1
  in call from init:start_em/1

if I place the escript into the ebin files it obviouosly find the waker module 
but is the .beam that is there!.


Do need I to include a "walker.app"  to allow script to find where my main 
function is from the zip archive?


Regards,  Angel



More information about the erlang-questions mailing list