[erlang-questions] Hiding user input in escript

17 views
Skip to first unread message

Michal Ptaszek

unread,
Apr 24, 2009, 3:19:58 AM4/24/09
to erlang-questions
Hello All,

Is it possible to disable echo while reading the data
from the stdin in escript?

What I would like to achieve is something similar to
`stty -echo`
in Unix shells.

Best regards,
--
Michal Ptaszek
www.erlang-consulting.com
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions

Bjorn Gustavsson

unread,
Apr 24, 2009, 5:30:43 AM4/24/09
to Michal Ptaszek, erlang-questions
On Fri, Apr 24, 2009 at 9:19 AM, Michal Ptaszek
<michal....@erlang-consulting.com> wrote:
> Hello All,
>
> Is it possible to disable echo while reading the data
> from the stdin in escript?
>

io:get_password/0

/Bjorn

--
Björn Gustavsson, Erlang/OTP, Ericsson AB

Michal Ptaszek

unread,
Apr 24, 2009, 6:40:06 AM4/24/09
to Bjorn Gustavsson, erlang-questions

----- "Bjorn Gustavsson" <bgust...@gmail.com> wrote:

> On Fri, Apr 24, 2009 at 9:19 AM, Michal Ptaszek
> <michal....@erlang-consulting.com> wrote:
> > Hello All,
> >
> > Is it possible to disable echo while reading the data
> > from the stdin in escript?
> >
>
> io:get_password/0
>

It seems it does not like me:

cat pass.erl
#!/usr/bin/env escript

main(_) ->
io:format("Password: "),
A = io:get_password(),
io:format("A = ~p~n", [A]).


./pass.erl:
Password: A = {error,{request,get_password}}

When it is running inside the Erlang shell, works perfectly.
What am I doing wrong?

BR
--
Michal Ptaszek
www.erlang-consulting.com

Bjorn Gustavsson

unread,
Apr 24, 2009, 8:53:49 AM4/24/09
to Michal Ptaszek, erlang-questions
On Fri, Apr 24, 2009 at 12:40 PM, Michal Ptaszek
<michal....@erlang-consulting.com> wrote:
>
> ----- "Bjorn Gustavsson" <bgust...@gmail.com> wrote:
>
>> On Fri, Apr 24, 2009 at 9:19 AM, Michal Ptaszek
>> <michal....@erlang-consulting.com> wrote:
>> > Hello All,
>> >
>> > Is it possible to disable echo while reading the data
>> > from the stdin in escript?
>> >
>>
>> io:get_password/0
>>
>
> It seems it does not like me:
>
> cat pass.erl
> #!/usr/bin/env escript
>
> main(_) ->
> io:format("Password: "),
> A = io:get_password(),
> io:format("A = ~p~n", [A]).
>
>
> ./pass.erl:
> Password: A = {error,{request,get_password}}
>
> When it is running inside the Erlang shell, works perfectly.
> What am I doing wrong?

Sorry, I only tested it inside an Erlang shell, not in escript.

The problem seems to be that escript uses the old shell, which
does not support any way to control the terminal.

We'll have a look at escript for the next release and see whether
it would be possible to have it run with the standard shell.

/Bjorn


>
> BR
> --
> Michal Ptaszek
> www.erlang-consulting.com
>

--

Björn Gustavsson, Erlang/OTP, Ericsson AB

Reply all
Reply to author
Forward
0 new messages