<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'>A config file has the syntax:<br><font face="times new roman,new york,times,serif"><br>[{Application1, [{Par11,Val11},...]},<br> ...,<br> {ApplicationN, [{ParN1,ValN1},...]}].</font><br><br>which means that the application is not specified in the file name but in the data in the actual file. So you can have configuration data for many applications in one file. So in your case you have defined configuration data for the application 'my_app_config' with key1. So if we define our minimal application my_app with config file in my_app.app and app.config:<br><br>$ cat my_app.app<br>{application,my_app,<br> [{description,"My App"},<br> {env,[{key1,"val .app"}]}<br> ]}.<br>$ cat app.config<br>[{my_app,[{key1,"val .config"}]}].<br><br>Then we can do:<br><br>$ erl<br>Erlang R15B (erts-5.9) [source] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]<br><br>Eshell V5.9 (abort with ^G)<br>1> application:start(my_app).<br>ok<br>2> application:get_env(my_app,key1).<br>{ok,"val .app"}<br><br>while:<br><br>$ erl -config app.config<br>Erlang R15B (erts-5.9) [source] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]<br><br>Eshell V5.9 (abort with ^G)<br>1> application:start(my_app).<br>ok<br>2> application:get_env(my_app,key1).<br>{ok,"val .config"}<br><br>Check in http://www.erlang.org/doc/design_principles/applications.html<br>more specifically:<br>http://www.erlang.org/doc/design_principles/applications.html#id74278<br><br>The problem of finding the file still remains of course.<br><br>Robert<br><br>P.S. Got a bit longer than expected here.<br><br><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Alexander 0xAX" <anotherworldofworld@gmail.com><br><b>To: </b>erlang-questions@erlang.org<br><b>Sent: </b>Wednesday, 9 January, 2013 3:39:00 PM<br><b>Subject: </b>Re: [erlang-questions] application:get_env return undefined<br><br><div dir="ltr"><div>Hello,<br></div><div><br></div><div>Thank you for replies. </div><div><br></div><div>I try to run my application without .config extenstion:</div><div><br></div><div>exec erl -config app -s test_app</div>
<div><br></div><div>Same result.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/1/9 Slava Yurin <span dir="ltr"><<a href="mailto:yurinvv@yandex.ru" target="_blank">yurinvv@yandex.ru</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hi Alexander.</div><div> </div><div>Please see <a href="https://github.com/nevar/sys_test" target="_blank">https://github.com/nevar/sys_test</a>.</div>
<div> </div><div>09.01.2013, 20:14, "Alexander 0xAX" <<a href="mailto:anotherworldofworld@gmail.com" target="_blank">anotherworldofworld@gmail.com</a>>:</div><blockquote><div><div class="h5"><div dir="ltr">
<div>Hello,</div><div> </div><div>I have simple test application with test.app.src file, test_app.erl and test_sup.erl</div><div> </div><div>Also i want to read config in my application. I have app.config:</div><div> </div>
<div>[<br> {my_app_config, <br> [{key1, "val"}]}<br>].</div><div> </div><div>I run my application:</div><div> </div><div>erl -boot start_sasl -config app.config -s test_app</div><div> </div><div>And now, after application successful starting i try to read my config:</div>
<div> </div><div>>application:get_env(test_app, my_app_config).</div><div>undefined</div><div> </div><div>Why? How can i correctly read config file?</div><div> </div><div>Thank you.</div></div></div></div><div class="im">
,<p>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a></p>
</div></blockquote></blockquote></div><br></div>
<br>_______________________________________________<br>erlang-questions mailing list<br>erlang-questions@erlang.org<br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote><br></div></body></html>