ybiC has asked for the wisdom of the Perl Monks concerning the following question:
I have an existing script to automate password resets for a passel o' Cisco switches.
The following snippet is my attempt at having the script prompt for old+new passwords
(instead of having them coded in the script's config parameters).
But it doesn't work.
Looks like keyboard-entered passwords aren't getting pushed(?) into the scalars.
Multiple "uninitialized value" errors result for each of lines 8, 21, 26.
Would any clueful Monks care to enlighten me on whatever fundamental concept/syntax I'm lacking?
cheers,
Don
striving for Perl Adept
1 #!/usr/bin/perl -w 2 # getpass.pl 3 4 use Term::ReadKey; 5 use Tie::IxHash; 6 use vars qw($key $t %passwds); 7 8 $t = tie(%passwds, Tie::IxHash, 9 'Enter old password:' => "$oldpass", 10 'Enter old enable password:' => "$oldenable", 11 'Enter new password:' => "$newpass", 12 'Confirm new password:' => "$newpassConf", 13 'Enter new enable password:' => "$newenable", 14 'Confirm new enable password:' => "$newenableConf", 15 ); 16 17 print "Prompting for passwords (won't appear on-screen)\n"; 18 foreach $prompt (keys (%passwds)) { 19 print "$prompt "; 20 ReadMode('noecho'); 21 chomp($prompt{$key} = <STDIN>); 22 ReadMode(0); 23 print "\n" 24 } 25 26 unless (("$newpass" eq "$newpassConf") and ("$newenable" eq "$ne +wenableConf")) 27 {die "\nNew password(s) confirmation didn't match. Tough be +ans. Try again.\n"}
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Scalars as hash keys?
by Fastolfe (Vicar) on Oct 26, 2000 at 22:34 UTC | |
by ybiC (Prior) on Oct 26, 2000 at 22:50 UTC | |
by Fastolfe (Vicar) on Oct 26, 2000 at 22:55 UTC | |
by ybiC (Prior) on Oct 26, 2000 at 23:12 UTC | |
Re: Scalars as hash keys?
by chromatic (Archbishop) on Oct 27, 2000 at 00:15 UTC | |
by Fastolfe (Vicar) on Oct 27, 2000 at 00:26 UTC | |
by ybiC (Prior) on Oct 27, 2000 at 00:50 UTC | |
by ybiC (Prior) on Oct 27, 2000 at 00:30 UTC | |
(code) RE: Scalars as hash keys? (solution!)
by ybiC (Prior) on Oct 27, 2000 at 08:34 UTC | |
Re: Scalars as hash keys?
by AgentM (Curate) on Oct 26, 2000 at 22:39 UTC | |
Re: Scalars as hash keys?
by ChOas (Curate) on Oct 27, 2000 at 15:18 UTC |
Back to
Seekers of Perl Wisdom