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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

password input 1

Status
Not open for further replies.

flawless69

Programmer
May 31, 2002
86
US
Anyone know of a way to have a user enter a password at the input prompt but for it to not be displayed to the screen?
Stars will work but I'd prefer no character display after the password prompt. --Derek

"Fear not the storm for this is where we grow strong."
 
Try this using Unix stty:

[tt]
print "Enter password: ";
system("stty -echo");
chomp($dir = <STDIN>);
system(&quot;stty echo&quot;); [/tt]
 
I imagine NT is out of the question. :) --Derek

&quot;Fear not the storm for this is where we grow strong.&quot;
 
perl -MTk -e &quot;$mw=MainWindow->new;$mw->Entry(-show=>'*')->pack;MainLoop();&quot; ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
use Win32::Console;
my $StdIn = new Win32::Console( STD_INPUT_HANDLE );
my $Password = &quot;&quot;;
$StdIn->Mode( ENABLE_PROCESSED_INPUT );
print &quot;Enter password: &quot;;

while( my $Data = $StdIn->InputChar( 1 ) )
{
if( &quot;\r&quot; eq $Data )
{
last;
}
elsif( &quot;\ch&quot; eq $Data )
{
if( &quot;&quot; ne chop( $Password ) )
{
print &quot;\ch \ch&quot;;
}
next;
}
$Password .= $Data;
print &quot;*&quot;;
}
print &quot;\nYour password is: '$Password'\n&quot;;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top