easco

easco

The Mix.Shell.IO module allows me to prompt the user for some information. I would like to use that functionality in a script I am writing to prompt the user for a password. Unfortunately it displays the user’s entry in cleartext on the screen.

I don’t see any way to entice that function to mask the input at the moment.

Is there another Erlang/Elixir function that might help me accomplish the same effect? For that matter, is there a shell command I could use with Mix.Shell.IO.cmd to collect a masked string and return it?

Showing Posts 1 to 10

OvermindDL1

OvermindDL1

Don’t know how to turn off echo’ing offhand, but I know the hex.publish takes a password that it immediately deletes as it is typed, maybe take a look at it’s code?

easco

easco OP

I discovered that there is an undocumented function :io.get_password() that reads input from the shell without echoing it and returns a password. That seems to be what I need ([erlang-questions] Getting a password from escript / I/O server introduction)

My code now reads:

    username = Mix.Shell.IO.prompt("username:")
    IO.write("password: ")
    password = :io.get_password()

For others looking to this solution, read the rest of the thread. This was a solution for me in one context, but may not be general purpose solution.

NobbZ

NobbZ

Unless you are developing something to integrate with mix, you should not use it. It is usually not included in production builds and will probably fail then.

hassan

hassan

Unless you are developing something to integrate with mix, you should not
use it. It is usually not included in production builds

“usually not” based on what? It seems to be in my production builds.

NobbZ

NobbZ

Then you either have mix mentioned in your (extra_)applications-list, or you are running you generated application on a machine that has elixir installed.

hassan

hassan

Then you either have mix mentioned in your (extra_)applications-list,

Nope.

are running you generated application on a machine that has elixir
installed.

“Elixir” or Erlang? It’s present on a system without Elixir but with
Erlang installed, but – I thought the whole point of a release was to
use the bundled version.

NobbZ

NobbZ

Just search the forum, there are plenty of threads because mix is not available in production or release. Its always suggested to not rely on mix when not in build time.

So if you have a proper release and access to mix, its probably a bug, so could you please explain how you built and run the release?

hassan

hassan

Just search the forum, there are plenty of threads because mix is not
available in production or release. Its always suggested to not rely on mix
when not in build time.

Who is talking about mix?!

The OP mentioned finding an undocumented function :io.get_password()
and you responded with:

“It is usually not included in production builds…”

So maybe in the future be more specific what you mean by “it”?

NobbZ

NobbZ

The OP… The subject… The code example…

Or do you want to say, that Mix.Shell.IO is not part of mix?

Also I said:

All “it”s are clearly refering to mix that I mentioned in the very same paragraph. Nothing there seems to be related to :io-module.

hassan

hassan

The OP… The subject… The code example…

You didn’t reply to the first post, but to the one that starts out
mentioning finding the :io.get_password() function.

All “it”s are clearly refering to mix that I mentioned in the very same
paragraph.

They definitely weren’t “clearly” referring to Mix from my reading, or
I wouldn’t have had the question I did.

And if we replace “it” in your statement with “mix”,

Unless you are developing something to integrate with mix, you
should not use mix.

That doesn’t seem meaningful to me :grinning_face:

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
thiagogsr
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews