PERL automation of .htpasswd
Posted on 1998-03-10
I have asked this question before as have many other people but I have never seen an anwser which solved my particular setup.
I need a PERL script which can automatically generate the .htpasswd file for use with .htaccess on an Apache server. I have only got access to PERL 5.001 and do not have the facility to upgrade nor use modules other than those available with the standard PERL distribution.
At present (as I am sure you are aware), to create a username and password pair I have to telnet in and then type:-
htpasswd -c file user
enter the password twice and then for each subsequent user do the same but minus the -c switch.
What I need is a PERL script which can do this by reading a text file of names and unencrypted passwords and then create the .htpasswd file of names and encrypted passwords. I understand that htpasswd uses something along the lines of:
cpw = crypt(pw,salt);
but how to use this in a PERL script to create my .htpasswd file I have no idea.
Given the example below I need a script to convert it into the appropriate .htpasswd file:
Thanks in advance