init:boot/1

Raimo Niskanen raimo@REDACTED
Sat Sep 15 09:55:39 CEST 2001


Vance Shipley wrote:
> 
> The example given in the documentation for init:boot/1
> shows the following example:
> 
>         erl -run foo -run foo bar -run foo bar baz 1 2
> 
>         This starts the Erlang runtime system and then
>         evaluates the following Erlang functions:
> 
>             foo:start()
>             foo:bar()
>             foo:bar([baz, "1", "2"]).
> 
> Fine, but what if I want?:
> 
>                 foo:bar(baz, "1", "2").
> 
> There doesn't seem to be a syntax for that. :(
> 

The possibilities are a bit limited, but the intention is just to be
able to call a tailored function in a module of your own, not to call
any function in any module with any arguments. 

As an exercise to the reader it is quite possible to write a function
my:eval([String]) that parses String and calls any functions with any
arguments:
	erl -run my eval 'foo:bar(baz, "1", "2"). init:stop().'

Hint: use erl_scan and erl_parse.


Please note that there seems to be a documentation error here:
	erl -run foo bar baz 1 2
really calls
	foo:bar(["baz", "1", "2"]),
not
	foo:bar([baz, "1", "2"]).

You can also try the following trick:
	echo "erlang:system_info(system_version). init:stop()." | erl -oldshell
if you are a Unix user. Or from a shell script:
	#!/bin/sh
	erl -oldshell <<-EOF
		erlang:system_info(system_version).
		init:stop().
	EOF

The -oldshell argument gives a shell that does not require a terminal.

Beware of the whitespaces after the dots. They are syntactically
essential.


/ Raimo Niskanen, Erlang/OTP, Ericsson UAB.



More information about the erlang-questions mailing list