> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> > <HTML>
In the future it would be most appreciated if you did not send HTML mail to the lists. It is not appreciated by many because it is virtually unreadable. Plain text is strongly recommended. http://www.expita.com/nomime.html > I'm using GNU textutils 2.0e on a RedHat Linux 6.2 box. I've written a bash > script to create a password based on the following criteria: certain > characters excluded, at least 10 characters long, and no repeated characters > (see below). I'm using mkpasswd to create the test password and "tr" to > remove the unwanted and duplicate characters. Ugh, can I call you a sadist? Those passwords are really awful. Fine for a first time temporary. But I hope you are not forcing users to remember passwords like hRK37s8Bue, yAJq8V01hw, and mb7CPzh68D! > When I run this script, it appears that none of the duplicate characters are > removed. I added the last line to double-check by attempting to remove the > duplicates -- without success. Is this a known bug? Thanks for your help > with this issue. I don't see the problem. I have a version 2.0e handy and it worked fine for me. > newpw=`mkpasswd -2 -l 10 -d 3 -C 3 | tr -ds 'l1O08B' '[:alnum:]'` Let's break this down into parts. Let's say that mkpasswd generates 'R9dNgl1Y2u' (which is did for me) and this is run through tr. echo R9dNgl1Y2u | tr -ds 'l1O08B' '[:alnum:]' R9dNgY2u The 'l' and the '1' were in the delete list and were deleted. Another few runs and I was able to get this next. echo cu227ORPwj | tr -ds 'l1O08B' '[:alnum:]' cu27RPwj Since the '2' is a repeated character and an alnum it was squeezed. The 'O' being in the delete list was deleted. Let's try another test. echo 1222234445aaabcd5647 | tr -ds 'l1O08B' '[:alnum:]' 2345abcd5647 Looks like it is working to me. What are you seeing? > pwlen=0 > until [ $pwlen -ge 11 ] > do > newpw=`mkpasswd -2 -l 10 -d 3 -C 3 | tr -ds 'l1O08B' '[:alnum:]'` > pwlen=`echo $newpw | wc -c` > echo -n "." > # echo -n $pwlen > # break > done > echo; echo $newpw > echo "$newpw" | tr -s '[:alnum:]' Looking at your script it looks like you are taking the long road. You are in a loop cutting out characters and retrying until you get one that does not have the characters to cut out. But they are just random characters to begin with. Perhaps you could make a longer string of random characters and just cut it down to the size you wanted in one step and remove the looping? Something like this? mkpasswd -2 -l 20 -d 6 -C 6 | tr -ds 'l1O08B' '[:alnum:]' | cut -c-10 Also, by squeezing out random characters which randomly happen to be repeated you are removing randomness. By analogy if you flip a coin you will get either heads or tails, leaving out the possibilities of landing on edge or of losing the coin during the toss. If you squeeze repeats out of a series of coin tosses you will end up with a predictable pattern that would not be there if you kept the randomness in place. Bob _______________________________________________ Bug-textutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-textutils