[erlang-questions] Getting a password from escript / I/O server introduction

Wes James <>
Fri Nov 25 06:14:46 CET 2011


Hi,

On Thu, Nov 24, 2011 at 1:34 AM, Mikhail Sobolev
<> wrote:

<snip>

>>
> Yes, what I expect is:
>
>> tmp $ ./q
>> Input >
>>  -> "yes\n"

I'm not sure how many times you need to type in the password. You
could read a file (tmp file) with a password or you could run your
script:

$ stty -echo
$ ./q
$ Input >
$ -> "password\n"
$ stty echo

or in a put in bash script

#!/bin/bash
stty -echo
./q
stty echo




<snip>


I tried:

#!/usr/bin/env escript

main(_) ->
    os:cmd("/bin/stty -echo"),
   io:format("Input -> "),
   {ok, Password} = io:fread("", "~s"),
    io:format(" -> ~p\n", [Password]),
    os:cmd("/bin/stty echo").

but the stty change probably only lived until the process returned so
had no effect.

-wes



More information about the erlang-questions mailing list