Created
October 4, 2021 12:06
-
-
Save tsuyo/96fee3b86581014f82558a1871d74f9f to your computer and use it in GitHub Desktop.
htpasswd_batch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
from subprocess import Popen,PIPE | |
dav_svn_passwd = '/etc/apache2/dav_svn.passwd' | |
if len(sys.argv) < 2: | |
print "Usage:", sys.argv[0], "<passwd.txt>" | |
sys.exit(0) | |
file = open(sys.argv[1]) | |
for entry in file.readlines(): | |
(user, passwd) = entry.strip().split('/')[1:3] | |
proc = Popen(["htpasswd", "-b", "-m", dav_svn_passwd, user, passwd], stdout=PIPE, stderr=PIPE) | |
print "add or change", user | |
stdout, stderr = proc.communicate() | |
print stdout | |
print stderr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment