A way to get a password in elixir (or erlang)

316 views
Skip to first unread message

Jamiel Almeida

unread,
Jul 24, 2014, 1:51:45 AM7/24/14
to elixir-l...@googlegroups.com
I've been toying around creating a program that needs to handle a credential to use somewhere, but the :io.get_password/0 and :io.setopts([echo: false]) only work on the shell, and not on escript, shebanged elixir script, or compiled elixir escript via mix escript.build.

one option I found online was using shell to read the value with "read -s varname" and passing that as an argument, but that's not a way I'd like to proceed.

Is there a way to have the :io.get_password behavior outside of the shell?

José Valim

unread,
Jul 24, 2014, 10:09:38 AM7/24/14
to elixir-l...@googlegroups.com
Is there a way to have the :io.get_password behavior outside of the shell?

As far as I know, no. :( I believe the current limitation was reported as a bug to Erlang.



José Valim
Skype: jv.ptec
Founder and Lead Developer


--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jamiel Almeida

unread,
Jul 24, 2014, 12:22:06 PM7/24/14
to elixir-l...@googlegroups.com
Ah, is there a way one can track those? is there a public bug tracker? I think it's a feature that would be very nice to have; or as I see it, a deficiency in the language/bug.
--
Jamiel Almeida

José Valim

unread,
Jul 24, 2014, 12:25:59 PM7/24/14
to elixir-l...@googlegroups.com
Erlang doesn't have yet a public bug tracker, bugs from the community are reported here: http://erlang.org/mailman/listinfo/erlang-bugs



José Valim
Skype: jv.ptec
Founder and Lead Developer


Jamiel Almeida

unread,
Jul 24, 2014, 12:57:21 PM7/24/14
to elixir-l...@googlegroups.com
Yeah, I know, but that also means I'd have to search for "unclosed" issues here http://erlang.org/pipermail/erlang-bugs/ .

Anyways... is there a way to read only one character from the keyboard without the "enter/return" key? I believe I could "fake" the get_password if there's a way to grab only one keystroke from the keyboard and then, maybe, printing a "\b " to the screen?

Thinking about alternatives I may have here. What would be a workaround to this that didn't involve loading that variable in the shell as an environment variable and probably tainting the command history, and that didn't expose the user if they were to scroll back?

Alexei Sholik

unread,
Jul 24, 2014, 1:29:37 PM7/24/14
to elixir-l...@googlegroups.com

Jamiel Almeida

unread,
Jul 24, 2014, 1:39:11 PM7/24/14
to elixir-l...@googlegroups.com
Alexei, thanks for that, it works pretty well.

Since I can't find the bug to the erlang list, I think I'll report it if I can't find it anywhere.

Thanks again!
Reply all
Reply to author
Forward
0 new messages