Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When entering a password with <STDIN> how can I hide it? 1

Status
Not open for further replies.

FrankFurter

Programmer
Jan 25, 2001
2
DE
Hi everybody,

I am using Active Perl 522 for WinNT. For a script it is necessary to enter passwords. How can I suppress the clear printout of the Passwords on screen or how can I substitute the clear printed word with f.e. ***** ?

Thanks for any help

 
there is a thread in this forum about the same thing..

you just need to turn echoing off. search for a thread with a similar title. its in here. adam@aauser.com
 
Thanks for the info. I tried to search first - honestly ;-)
However even to words like "Perl" I do not get any hits.
What's wrong & what do you mean by turning echoing off?
 
He means the "keyword search" at the top of this page. However, it's currently down, so the other option you have is to search through this forum manually.
Either way, echoing is a function of a terminal to respond to keystrokes by displaying characters. I understand the process in Linux (through stty), but i am not familiar enough with Windows to tell you how to turn it off. You could try keyword searching (term, terminal, echo, ?), or reading through perl documentation. There's probably some function in the Win32 module, maybe the POSIX module, or you could hack something together by reading the source code of the windows port of maybe the Term set of modules.
Sorry i don't have an answer, but i hope i could at least point you somewhere helpful for now. Try searching this perl forum tomarrow; this site is pretty okay about being up most of the time.

"If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
One thing you can always do to help yourself first, besides "keyword search" at the top of this page, is to see if the perldocs have information about your topic. For example here's just *some* of what I got back on Redhat 6.1 Linux(I don't know how to do this on Activestate Perl, but there's got to be a way to get perldoc info) when I entered "perldoc -q password":

=head1 Found in /usr/lib/perl5/5.00503/pod/perlfaq8.pod

=head2 How do I ask the user for a password?

(This question has nothing to do with the web. See a different
FAQ for that.)

There's an example of this in L<perlfunc/crypt>). First, you put
the terminal into &quot;no echo&quot; mode, then just read the password
normally. You may do this with an old-style ioctl() function, POSIX
terminal control (see L<POSIX>, and Chapter 7 of the Camel), or a call
to the B<stty> program, with varying degrees of portability.

You can also do this for most systems using the Term::ReadKey module
from CPAN, which is easier to use and in theory more portable.

use Term::ReadKey;

ReadMode('noecho');
$password = ReadLine(0);

---------------------------------------

Looks to me like that may answer your question.

If you're doing it with a Perl CGI script, outputing HTML, you can use a &quot;input&quot; form field with TYPE=&quot;PASSWORD&quot;, and that will display an asterisk for every character the user types for the password.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top