How do I ask the user for a password?

B

Bernd Nies

The perl FAQ says:

use Term::ReadKey;

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

Is this also possible without installing an additional module?

This module is not on a Solaris 8 Perl 5.005_03 standard perl
installation and we can't/don't want install additional modules and the
hundred dependencies.

Thanks in advance.

Regards,
Bernd
 
O

optional

Try this;

chomp(my $ans = `stty -noecho; read ans; echo \$ans`);

print "ans = $ans\n";

Siva
 
E

Eric Schwartz

Bernd Nies said:
The perl FAQ says:

use Term::ReadKey;

Is this also possible without installing an additional module?

This module is not on a Solaris 8 Perl 5.005_03 standard perl
installation and we can't/don't want install additional modules and the
hundred dependencies.

A) That perl is ancient beyond belief. There are innumerable bugs and
security holes. Please consider moving to a perl released in the
current millenium.

B) What's wrong with modules? We hear this now and again, but I
honestly don't understand why you'd want to reinvent the wheel,
usually poorly, rather than use well-tested and widely-used code
that already solves your problem.

That's not a comment on your coding skill, BTW-- it's just that
anyone's first stab at solving a problem is likely to be inferior
to code which has been around and bugfixed for quite some time.

C) Term::ReadKey doesn't depend on anything outside the core Perl
modules. If you read the source, you'll see:

require Exporter;
require AutoLoader;
require DynaLoader;
use Carp;

all of which are distributed with Perl. It's possible Carp might
not be with such an ancient perl, but I believe it was. I know for
a fact it's included with all modern (i.e., in the last, say, 5
years) versions of perl.

-=Eric
 
C

Charles DeRykus

The perl FAQ says:

use Term::ReadKey;

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

Is this also possible without installing an additional module?

This module is not on a Solaris 8 Perl 5.005_03 standard perl
installation and we can't/don't want install additional modules and the
hundred dependencies.
system("stty -echo") == 0 or die "can't turn off echo: $?";
....
system("stty echo") == 0 or die "can't turn on echo: $?";

will work on some Unix-based hosts

hth,
 
B

Bernd Nies

Thanks for your answer.

Just to explain my motives: That perl version is on some hundred
Solaris 8 hosts of a customer. I can't expect him to install a whole
new perl distribution or modules for just one small script.

Regards,
Bernd
 
X

xhoster

Bernd Nies said:
The perl FAQ says:

use Term::ReadKey;

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

Is this also possible without installing an additional module?


print "May I have your password please? (If someone is watching over
your shoulder, shoo them away).\n";

my $password=<STDIN>; chomp $password;

print "\n" foreach 1..100;

This module is not on a Solaris 8 Perl 5.005_03 standard perl
installation and we can't/don't want install additional modules and the
hundred dependencies.

Xho
 
E

Eric Schwartz

Bernd Nies said:
Thanks for your answer.

Whose answer? Please quote some context when you reply to someone, or
else we have no idea what you're talking about or who you're talking
to.

-=Eric
 
B

Bernd Nies

Eric said:
Whose answer? Please quote some context when you reply to someone, or
else we have no idea what you're talking about or who you're talking
to.

I was replying to you and your posting about 'TERM::ReadKey'.
GoogleGroups does not quote the original text by default.

Regards,
Bernd
 
B

Bernd Nies

optional said:
Try this;

chomp(my $ans = `stty -noecho; read ans; echo \$ans`);

print "ans = $ans\n";

Siva

Thanks for that hint. The following code works fine for me:

my $phrase;
print "Enter passphrase:\n";
system('stty', '-echo');
$phrase = <STDIN>;
system('stty', 'echo');
chomp($phrase);

Regards,
Bernd
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top