I am writing a script in common lisp now. It needs to ask the user to
input the password. I can use (read-line) to do that, but it will echo
user's password in the screen. How can I suppress the password echo?
How can I suppress echo in GNU CLISP?
On May 15, 10:09 am, Brian Jiang <········@gmail.com> wrote:
> I am writing a script in common lisp now. It needs to ask the user to
> input the password. I can use (read-line) to do that, but it will echo
> user's password in the screen. How can I suppress the password echo?
> How can I suppress echo in GNU CLISP?
you can write a ffi wrapper to
char *getpass(const char *prompt) //#include <unistd.h>
using clisp's ffi or cffi/uffi.
hth,
mac
From: Zach Beane
Subject: Re: How to get the password input from user without echo it?
Date:
Message-ID: <m363tf5plf.fsf@unnamed.xach.com>
Brian Jiang <········@gmail.com> writes:
> I am writing a script in common lisp now. It needs to ask the user to
> input the password. I can use (read-line) to do that, but it will echo
> user's password in the screen. How can I suppress the password echo?
> How can I suppress echo in GNU CLISP?
Using EXT:WITH-KEYBOARD might help. It's documented here:
http://clisp.cons.org/impnotes.html#with-kbd
Zach
On May 16, 3:34 am, Zach Beane <····@xach.com> wrote:
> Brian Jiang <········@gmail.com> writes:
> > I am writing a script in common lisp now. It needs to ask the user to
> > input the password. I can use (read-line) to do that, but it will echo
> > user's password in the screen. How can I suppress the password echo?
> > How can I suppress echo in GNU CLISP?
>
> Using EXT:WITH-KEYBOARD might help. It's documented here:
>
> http://clisp.cons.org/impnotes.html#with-kbd
>
> Zach
Excellent!!! Thank you very much.
I can implement the function now as follows:
(ext:with-keyboard
(loop
:with str = (make-array 20 :element-type 'character :fill-pointer
0)
:with key
:for char = (read-char ext:*keyboard-input*)
:do
(cond ((ext:char-key char))
((setq key (character char))
(cond ((eql key #\Return)
(return str)
)
(t
(vector-push key str))
)))
))
On May 16, 10:59 am, Brian Jiang <········@gmail.com> wrote:
> On May 16, 3:34 am, Zach Beane <····@xach.com> wrote:
>
> > Brian Jiang <········@gmail.com> writes:
> > > I am writing a script in common lisp now. It needs to ask the user to
> > > input the password. I can use (read-line) to do that, but it will echo
> > > user's password in the screen. How can I suppress the password echo?
> > > How can I suppress echo in GNU CLISP?
>
> > Using EXT:WITH-KEYBOARD might help. It's documented here:
>
> > http://clisp.cons.org/impnotes.html#with-kbd
>
> > Zach
>
> Excellent!!! Thank you very much.
> I can implement the function now as follows:
>
> (ext:with-keyboard
> (loop
> :with str = (make-array 20 :element-type 'character :fill-pointer
> 0)
> :with key
> :for char = (read-char ext:*keyboard-input*)
> :do
> (cond ((ext:char-key char))
> ((setq key (character char))
> (cond ((eql key #\Return)
> (return str)
> )
> (t
> (vector-push key str))
> )))
> ))
Changed a little, to support Backspace.
(ext:with-keyboard
(loop
:with str = (make-array 20 :element-type 'character :fill-pointer
0)
:with key
:for char = (read-char ext:*keyboard-input*)
:do
(cond ((ext:char-key char))
((setq key (character char))
(cond ((eql key #\Return)
(return str)
)
((eql key #\Backspace)
(when (> (length str) 0)
(vector-pop str))
)
(t
(vector-push key str))
)))
))
Brian Jiang <········@gmail.com> writes:
> On May 16, 10:59 am, Brian Jiang <········@gmail.com> wrote:
>> On May 16, 3:34 am, Zach Beane <····@xach.com> wrote:
>>
>> > Brian Jiang <········@gmail.com> writes:
>> > > I am writing a script in common lisp now. It needs to ask the user to
>> > > input the password. I can use (read-line) to do that, but it will echo
>> > > user's password in the screen. How can I suppress the password echo?
>> > > How can I suppress echo in GNU CLISP?
>>
>> > Using EXT:WITH-KEYBOARD might help. It's documented here:
>>
>> > http://clisp.cons.org/impnotes.html#with-kbd
>>
>> > Zach
>>
>> Excellent!!! Thank you very much.
>> I can implement the function now as follows:
>>
> Changed a little, to support Backspace.
Notice that most unix password reader just don't support backspace,
which allows you to include backspaces or delete codes in your
passwords, as well as most other control codes.
--
__Pascal Bourguignon__
> Notice that most unix password reader just don't support backspace,
> which allows you to include backspaces or delete codes in your
> passwords, as well as most other control codes.
This has pros and cons: Linux login allows for backspace to correct
mistakes done while entering the password. I find this to be very
convenient. Your choice.
Pascal J. Bourguignon <···@informatimago.com> wrote:
> Notice that most unix password reader just don't support backspace,
> which allows you to include backspaces or delete codes in your
> passwords, as well as most other control codes.
I've just tried this on Linux, OpenBSD, Solaris, AIX and HPUX (the
architectures available to be right here); only HPUX had this
brokenness. So I'd hardly call it `most'.
-- [mdw]
From: Frank Goenninger DG1SBG
Subject: [OT] Re: How to get the password input from user without echo it?
Date:
Message-ID: <lzve15xro0.fsf_-_@goenninger.net>
Mark Wooding <···@distorted.org.uk> writes:
> Pascal J. Bourguignon <···@informatimago.com> wrote:
>
>> Notice that most unix password reader just don't support backspace,
>> which allows you to include backspaces or delete codes in your
>> passwords, as well as most other control codes.
>
> I've just tried this on Linux, OpenBSD, Solaris, AIX and HPUX (the
> architectures available to be right here); only HPUX had this
> brokenness.
The brokenness is on your side, not on HP-UX side. How did you test
this? With which terminal settings? hpterm or xterm? ... And where did
you read that supporting Backspace or Delete as editing controls is
required for password input?
[Using HP-UX here for production environments]
Best,
Frank
--
Frank Goenninger
frgo(at)mac(dot)com
"Don't ask me! I haven't been reading comp.lang.lisp long enough to
really know ..."