Y
Yang Zhang
Hi, how do I do getpass() in ruby? Thanks!
Thanks for prompting me to provide some context. getpass() is a
standard POSIX function, described here:
http://www.opengroup.org/pubs/online/7908799/xsh/getpass.html
Thanks for prompting me to provide some context. getpass() is a
standard POSIX function, described here:
http://www.opengroup.org/pubs/online/7908799/xsh/getpass.html
getpass() is not a POSIX anything.
From the manpage:
DESCRIPTION
This function is obsolete. Do not use it.
...
CONFORMING TO
Present in SUSv2, but marked LEGACY. Removed in POSIX.1-2001.
In theory, using Ruby/DL should work, like
require 'dl/import'
module LibC
extend DL::Importable
dlload 'libc.so.6'
extern 'char *getpass( const char * prompt )'
end
In theory, theory and practice are the same.
/usr/lib/ruby/1.8/dl/import.rb:126:in `symbol': can't find the symbol
`getpass' (RuntimeError)
from /usr/lib/ruby/1.8/dl/import.rb:145:in `import'
from /usr/lib/ruby/1.8/dl/import.rb:61:in `extern'
But this works:
require 'dl'
module LibC
extend self
LIB=DL.dlopen('libc.so.6')
SYMS={ :getpass => LIB['getpass','SS'] }
def getpass prompt
r,rs = SYMS[:getpass].call prompt
return r
end
end
Again, don't use this. Use Highline instead.
--Ken
Sorry if I'm doing this wrong, but how do I get off the mailing list? I
can't figure it out.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.