Re: [Haskell-cafe] Disable echo in POSIX terminal
On Fri, 9 Nov 2007, Derek Elkins wrote: Pointless frobbing but is there any issue with setting the echo to False when it is already False? Otherwise not checking seems to both simpler and quicker (not that performance matters), i.e. getpasswd h = do wasEnabled - hGetEcho h hSetEcho h False str - hGetLine h hSetEcho wasEnabled return str Should one enclose this in 'bracket'? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Disable echo in POSIX terminal
Hi I've written a little Haskell program to get information from a MySQL database (great thanks to anybody reading this who works on HSQL, by the way) but I want to keep the user's password concealed, obviously. Currently I prompt for it from the terminal, but the problem is that it's echoed just like all other input. I would like to disable input echo when asking for the password, but I'm not sure how. I notice there's a System.POSIX.Terminal module, but I have no idea how to use it, or whether it will do what I want. Any ideas would be greatly appreciated. http://haskell.org/hoogle/?q=echo A quick Hoogle search for echo suggests hSetEcho, so perhaps hSetEcho stdin False would work. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Disable echo in POSIX terminal
I never used System.POSIX.Terminal myself but from what I read in the haddock documentation I think this function can help you. import System.Posix.Types (Fd) import System.Posix.Terminal disableEcho :: Fd - IO () disableEcho fd = do attribs - getTerminalAttributes fd setTerminalAttributes fd (withoutMode attribs EnableEcho) Immediately On Nov 9, 2007 4:59 PM, Taylor Venable [EMAIL PROTECTED] wrote: Hello all, I've written a little Haskell program to get information from a MySQL database (great thanks to anybody reading this who works on HSQL, by the way) but I want to keep the user's password concealed, obviously. Currently I prompt for it from the terminal, but the problem is that it's echoed just like all other input. I would like to disable input echo when asking for the password, but I'm not sure how. I notice there's a System.POSIX.Terminal module, but I have no idea how to use it, or whether it will do what I want. Any ideas would be greatly appreciated. Best regards. -- Taylor Venable [EMAIL PROTECTED] http://real.metasyntax.net:2357/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Disable echo in POSIX terminal
On Fri, 2007-11-09 at 10:59 -0500, Taylor Venable wrote: Hello all, I've written a little Haskell program to get information from a MySQL database (great thanks to anybody reading this who works on HSQL, by the way) but I want to keep the user's password concealed, obviously. Currently I prompt for it from the terminal, but the problem is that it's echoed just like all other input. I would like to disable input echo when asking for the password, but I'm not sure how. I notice there's a System.POSIX.Terminal module, but I have no idea how to use it, or whether it will do what I want. Any ideas would be greatly appreciated. Best regards. In C you usually use: getpasswd (http://docsrv.sco.com:507/en/man/html.S/getpasswd.S.html) I cannot find it System.Posix, so you might have to write your own FFI bindings. Otherwise, you can play around with the terminal modes from: http://haskell.org/ghc/docs/latest/html/libraries/unix-2.2.0.0/System-Posix-Terminal.html#t%3ATerminalMode Good luck! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Disable echo in POSIX terminal
On Nov 9, 2007 5:09 PM, Neil Mitchell [EMAIL PROTECTED] wrote: A quick Hoogle search for echo suggests hSetEcho, so perhaps hSetEcho stdin False would work. Ops, Neil sent while I was still writing, I didn't know the existance of this function. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Disable echo in POSIX terminal
On Fri, 9 Nov 2007 16:09:57 + Neil Mitchell [EMAIL PROTECTED] wrote: Hi I've written a little Haskell program to get information from a MySQL database (great thanks to anybody reading this who works on HSQL, by the way) but I want to keep the user's password concealed, obviously. Currently I prompt for it from the terminal, but the problem is that it's echoed just like all other input. I would like to disable input echo when asking for the password, but I'm not sure how. I notice there's a System.POSIX.Terminal module, but I have no idea how to use it, or whether it will do what I want. Any ideas would be greatly appreciated. http://haskell.org/hoogle/?q=echo A quick Hoogle search for echo suggests hSetEcho, so perhaps hSetEcho stdin False would work. Oh my, I completely forgot about Hoogle and missed those obvious functions. That's it exactly. Thanks very much for the pointers! -- Taylor Venable [EMAIL PROTECTED] http://real.metasyntax.net:2357/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Disable echo in POSIX terminal
I this there's no need for a binding How about this? import Control.Monad (when) import System.IO getpasswd :: Handle - IO String getpasswd h = do wasEnabled - hGetEcho h when wasEnabled (hSetEcho h False) str - hGetLine h when wasEnabled (hSetEcho h True) return str On Nov 9, 2007 5:20 PM, Thomas Schilling [EMAIL PROTECTED] wrote: On Fri, 2007-11-09 at 10:59 -0500, Taylor Venable wrote: Hello all, I've written a little Haskell program to get information from a MySQL database (great thanks to anybody reading this who works on HSQL, by the way) but I want to keep the user's password concealed, obviously. Currently I prompt for it from the terminal, but the problem is that it's echoed just like all other input. I would like to disable input echo when asking for the password, but I'm not sure how. I notice there's a System.POSIX.Terminal module, but I have no idea how to use it, or whether it will do what I want. Any ideas would be greatly appreciated. Best regards. In C you usually use: getpasswd (http://docsrv.sco.com:507/en/man/html.S/getpasswd.S.html) I cannot find it System.Posix, so you might have to write your own FFI bindings. Otherwise, you can play around with the terminal modes from: http://haskell.org/ghc/docs/latest/html/libraries/unix-2.2.0.0/System-Posix-Terminal.html#t%3ATerminalMode Good luck! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Disable echo in POSIX terminal
On Fri, 2007-11-09 at 17:41 +0100, Alfonso Acosta wrote: I this there's no need for a binding How about this? import Control.Monad (when) import System.IO getpasswd :: Handle - IO String getpasswd h = do wasEnabled - hGetEcho h when wasEnabled (hSetEcho h False) str - hGetLine h when wasEnabled (hSetEcho h True) return str Pointless frobbing but is there any issue with setting the echo to False when it is already False? Otherwise not checking seems to both simpler and quicker (not that performance matters), i.e. getpasswd h = do wasEnabled - hGetEcho h hSetEcho h False str - hGetLine h hSetEcho wasEnabled return str ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe