Hey Guys, Well ive been racking my brains out over the last 2 days trying to do this final part of my usermanagement system. So far ive finally got most of the password update working. Ive got it to check for existing usernames, then store it to my passwords.txt file. But now i also need to get it to update another 3 data/password files that also include the usernames and passwords. But i cannot work out how to do it, ive tried to call an external script, implement part of a script into my current and nothing seems to be working. Any ideas would be great, thanks! This is what i have;

# # Start Update existing user # # Determine that the -u (update) trigger is used if ($option eq "-u") { # Print update user heading print "\n\n\n--- Update User Password Menu --- \n"; print "\nEnter Your Current User Name --> : "; # User inputs username they wish to update. assigned to $userName2 not + to confuse with earlier chomp ($userName2 = <>); # Get user to put in the current password for that username print ("Enter Your Current Password:"); # Use the system to stop echo'ing whats typed up on the screen system ("stty -echo"); # Assign the thier input password as a string $inputline3 $inputline3 = <STDIN>; # Turn echo back on for input to come up system ("stty echo"); chop ($inputline3); # Encrypt the input password again (using thier username as the $salt) + to compare it with the password on file $salt = $userName2; $encryptpw2 = crypt ($inputline3,$salt); # Use open command to open the passwords.txt file as a filehande open my $fh, "<", 'passwords.txt' or die "Can't open password file: $! +"; while ( my $line = <$fh> ) { chomp $line; # Split up and assign the password.txt file into $name = username +and $passwd = encrypted password my ( $name, $passwd ) = split /:/, $line; # Scan through file unless they match usernames next unless $name eq $userName2; # If username found, match input password with password on file (b +oth already encrypted) if ($encryptpw2 eq $passwd) { # If they match, continue to ask for new password print ("\nEnter Your new password:"); system ("stty -echo"); $newpass = <STDIN>; system ("stty echo"); chop ($newpass); print ("\nPlease enter your new password in again:"); system ("stty -echo"); $newpass2 = <STDIN>; system ("stty echo"); chop ($newpass2); } # If password does not match, script dies else { die ("\n\nYour Passwords Did Not Match, Please Try running the scr +ipt again. \n\n"); } # Check to see if new input passwords match if ($newpass eq $newpass2) { # Encrypt the new password and assign it to $encryptpw3 $salt2 = $userName2; $encryptpw3 = crypt ($newpass2,$salt2); # Replace old password with new one stored in file use Tie::File; my $file_name = 'passwords.txt'; # Input file into an array tie @array, 'Tie::File', $file_name or die; for (@array) { # Search for $encryptpw2 and replace with $encryptpw3 s/$encryptpw2/$encryptpw3/g; } untie @array; # If successful print next statement print ("\n\nYour Username and Password have been updated and saved!"); } # Otherwise if new passwords do not match, show and die elsif ($newpass ne $newpass2) { die ("\n\nYour Passwords Did Not Match, Please Try again. \n\n"); } } # Update user finished Take next input from user print "\nPlease input your next Option ( -u,-d,-h,-q ) --> : "; chomp ($option = <>); }

I would like to also somehow print a statement about each file to. eg,
file1.dat; user id found, password updated file2.dat; user id not found, password not updated.
Please Help!

In reply to User Management System; Password Updating by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.