erl in unix pipe?

Anthony Howe achowe@REDACTED
Fri Jan 21 15:19:09 CET 2022


I've not had occasion before now to try to use erl in a unix pipe.  I want to
find the OTP major release for a shell script.

First attempt almost works but spits out a termination message that unix tools
do not.  Plus the shell version and prompts are present; no quiet option.

elf$ echo 'erlang:system_info(compat_rel).'| erl
Eshell V11.2.2  (abort with ^G)
1> 23
2> *** Terminating erlang (nonode@REDACTED)


I found -noshell, so I try assorted, which print nothing and don't quit:

elf$ echo 'erlang:system_info(compat_rel).'| erl -noshell
^C
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution

elf$ echo 'erlang:system_info(compat_rel). init:stop().'| erl -noshell
^C
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution

elf$ echo 'erlang:system_info(compat_rel), init:stop().'| erl -noshell
^C
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
elf$ echo 'io:format("~p~n",[system_info(compat_rel))]).'| erl -noshell -s init stop
elf$

Google some and I find try:

elf$ erl -noshell -s erlang system_info compat_rel
{"init terminating in
do_boot",{badarg,[{erlang,system_info,[[compat_rel]],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot
({badarg,[{erlang,system_info,[[_]],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done
elf$


How does one pipe Erlang statements into erl and pipe the output?

Wishes Erlang (erl) behaved more like unix tools.

-- 
Anthony C Howe
achowe@REDACTED                                   BarricadeMX & Milters
http://snert.com/    http://nanozen.snert.com/     http://snertsoft.com/


More information about the erlang-questions mailing list