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

Password input

Status
Not open for further replies.

xjc539w

IS-IT--Management
Aug 5, 2003
11
0
0
US
Aside from using the Term::ReadKey package, is there a recommended approach to accepting input as a password without echoing back the characters in a Windows (2000/XP) environment?
 
Have you tried shelling `@echo off`?, won't be too portable though.

Just a thought
--Paul
 
Paul,

Thanks, I tried that with this code:
`@echo off`;
print "Password: ";
chomp ($pass1 = <STDIN>);
`@echo on`;

but received the following:
'off' is not recognized as an internal or external command,
operable program or batch file.
Password:

Am I missing something?
 
Try it without the &quot;@&quot;.

Also, while the backticks should work, I would use
&quot;system&quot; instead, e.g.,
Code:
$somevar = system(qq(echo off));


 
Mike,

Thanks for the reply, but I had tried with and without the @. I did attempt to execute with the system call as suggested. NO errors, but the input still echoed.

thanks
al
 
Yes, sorry about that. I felt very sure that worked, and was quite shocked when I tried it myself
(after I posted, duh) and found it didn't.

It seems to me it once did work this way, but I may be very
out-of-date on this or simply mistaken.

Again, sorry I mislead you.
 
I think you need to say @echo off, but within backticks, perl is interpolating values and is trying to find an array called @echo (bet you're not running under strict, are you?). You could try making a system call and use single quotes or escape the @, but I'm still not sure something like that works. Isn't setting @echo changing the shell, and doesn't a new shell get spawned for every sytem call? Dunno, try and see.

----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top