httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marty Landman <>
Subject Re: [users@httpd] htpasswd in cgi (shell script)
Date Wed, 25 Jan 2006 14:35:03 GMT
At 11:11 AM 1/24/2006, Rodrigo Monteiro wrote:

>I'm using the httpd authentication (.htaccess and .htpasswd) for an
>cgi-bin/test dir. What I'm trying to do is another cgi (in shell
>script) that changes this file (cgi-bin/test/.htpasswd). I'm using the
>-m parameter in htpasswd to create the users.
># cat .htpasswd
>The user is admin and the password is admin.
>How can I encrypt the string "admin" to compare with the string in the

Rodrigo I would approach this by using Perl's backtick operator to execute 
the htpasswd system command from within the program.

my $tmpPW = '/tmp/pswd';
my $res = `htpasswd -cb $tmpPW admin admin`;

if($res eq 'Adding password for user admin')
#  read $tmpPW and your .htpasswd file
#  compare and act accordingly
#  delete (Perl unlink function) $tmpPW
else { die "htpasswd command failed: $!\n" }

Just an overview of how I'd code it.

FWIW it looks to me like you're trying to write a password application 
using htaccess as your base. Personally I'd not got that way, ymmv.


Marty Landman, Face 2 Interface Inc. 845-679-9387
Webmaster's Bulletin Board:
Web Installed Formmail:  

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message