[erlang-questions] escript and archives

Angel J. Alvarez Miguel clist@REDACTED
Tue Oct 18 10:47:31 CEST 2011


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",
				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", 

	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:



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

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

but then escript doesnt find the walker file:
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