# Erlang release app passing command line parameters

**URL:** <https://erlangforums.com/t/erlang-release-app-passing-command-line-parameters/1087>\
**Category:** Questions / Help\
**Tags:** rebar3, releases\
**Created:** [February 16, 2022, 9:25pm UTC](https://erlangforums.com/t/erlang-release-app-passing-command-line-parameters/1087 "2022-02-16T21:25:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdbergmann](https://erlangforums.com/user_avatar/erlangforums.com/mdbergmann/32/1243_2.png) [@mdbergmann](https://erlangforums.com/u/mdbergmann)\
**Post date:** [February 16, 2022, 9:25pm UTC](https://erlangforums.com/t/erlang-release-app-passing-command-line-parameters/1087/1 "2022-02-16T21:25:59Z")

</div>

Hello.

I’ve searched now a bit for this in various places. Supposedly it should work with escript.  
My rebar3 project, when I tell it to create a ‘release’, it seems to create some scripts that allow to start the application. In particular with specifying `{extended_start_script, true}` I get many options. But it’s not clear to me what I have to do to allow passing arbitrary parameters and make the application start as daemon, since it is a server application.  
Any advice would be welcome.

Manfred

---

<div class="post-metadata">

**Author:** ![MGreim](https://erlangforums.com/letter_avatar_proxy/v4/letter/m/e8c25b/32.png) [@MGreim](https://erlangforums.com/u/MGreim)\
**Post date:** [March 25, 2022, 3:45pm UTC](https://erlangforums.com/t/erlang-release-app-passing-command-line-parameters/1087/2 "2022-03-25T15:45:05Z")

</div>

Hello Manfred,

I am not an Erlang Guru but for me it works for LINUX as follows:

Lets assume the name of the project is: wf  
`rebar3 as prod release`  
is generating a shell script wf in  
`wf/_build/prod/rel/wf/bin`

with  
`./wf daemon`  
you may start this application in the background.  
If you like to start it from system V write a  
a script for example  
`wfstart`

in

`/etc/init.d`

This script may contain beneath others:

```erlang
export RUN_ERL_LOG_GENERATIONS=99
export RUN_ERL_LOG_MAXSIZE=2000000
/srv/www/cgi-bin-wf/wf/_build/prod/rel/wf/bin/wf daemon

```

All this environment optional variables you may find at:  
[https://www.erlang.org/doc/man/run\_erl.html](https://www.erlang.org/doc/man/run_erl.html)

Finally you must link the  
the init.d script to the runlevel subdirectories  
/etc/rc3.d

Best with  
update-rc.d

Of course you may use system.d, but I don’t understand it.

If you rapplicateion is finally running you may connect to shell of the application, for example  
to reload a module  
l(module).  
etc. with  
`to_erl /tmp/erl_pipes/wf@x800/erlang.pipe.1`

where x800 is the name of your machine.

As said above, that maybe a dirty hack, but for me it works.  
Markus

---

<div class="post-metadata">

**Author:** ![dischoen](https://erlangforums.com/user_avatar/erlangforums.com/dischoen/32/695_2.png) [@dischoen](https://erlangforums.com/u/dischoen)\
**Post date:** [January 18, 2023, 8:27pm UTC](https://erlangforums.com/t/erlang-release-app-passing-command-line-parameters/1087/3 "2023-01-18T20:27:43Z")

</div>

Hi Manfred,

you probably have figured it all out in the meantime…  
I just needed command-line arguments myself, so I looked it up.  
Maybe it will save some time for someone…

You could use init:get\_arguments/0 or init:get\_argument/1 for the job.  
You pass command lines after \<your\_release\> daemon, and  
with get\_arguments() you will receive all arguments commandline.  
Or with get\_argument(arg) you will get only this specific one.

` io:format("all flags: ~p~n", [init:get_arguments()]),`

```erlang
$ bin/bumbelbee console -a a1 a2 -b b1 b2 b3 -longer trees grow slow
[..]
Erlang/OTP 25 [erts-13.1.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:30] [jit:ns]

all flags: [{root,["/home/dieter/plazground/BEAM/erlang/bumbelbee/_build/default/rel/bumbelbee"]},
             {bindir,["/home/dieter/.asdf/installs/erlang/25.1.2/erts-13.1.2/bin"]},
             {progname,["bumbelbee"]},
             {home,["/home/dieter"]},
             {kernel,["shell_history","enabled"]},
             {boot,["/home/dieter/plazground/BEAM/erlang/bumbelbee/_build/default/rel/bumbelbee/releases/0.1.0/start"]},
             {mode,["embedded"]},
             {boot_var,["SYSTEM_LIB_DIR",
                        "/home/dieter/.asdf/installs/erlang/25.1.2/lib"]},
             {config,["/home/dieter/plazground/BEAM/erlang/bumbelbee/_build/default/rel/bumbelbee/releases/0.1.0/sys.config"]},
             {sname,["bumbelbee"]},
             {setcookie,["bumbelbee_cookie"]},
             {a,["a1","a2"]},
             {b,["b1","b2","b3"]},
             {longer,["trees","grow","slow"]}]

```
