#!/usr/bin/perl ################################################################# # # createpass.pl Creates file for adding passwords # # Takes information from class roster and creates file with # usernames and passwords. # INPUT FILE: course.txt OUTPUT FILE: passadd # # Created by: Al Bento, University of Baltimore ################################################################# # # INFILE format: last, first[, junior]:4digit:email # OUTFILE format: user add - c "name" uname # # uname = lowercase (1st letter of 1st name + all of last name w/o spaces) # passwd = crypt(4digit,4digit) # name = last + space + first # ################################################################# $startfile = "course.txt"; # input file (from Class Roster) $endfile = "passadd"; # output file (list of members) open (INFILE, "./$startfile") || die "Can't open start File"; open (OUTFILE, ">./$endfile") || die "Can't open end file"; foreach (sort ()) # alphabetize students { s/\s*$//; # delete extraneous space s/,\s/,/g; ($lastfirst, $digits, $email) = split /:/, $_, 5; ($last, $first, $jr) = split /,/, $lastfirst, 3; $last =~ s/\s//g; # remove spaces from last names # like "De Niro" when creating username $_ = join ':', (lc(join '', substr($first, 0, 1), $last)), # uname ($digits); # plain text passwd $_ =~ s/\s:/:/g; # delete extra spaces print OUTFILE "$_\n"; } close (INFILE); close (OUTFILE); chmod (0644,$endfile);