Created
March 1, 2010 10:42
-
-
Save dekz/318264 to your computer and use it in GitHub Desktop.
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 | |
import os | |
import sys | |
import subprocess | |
import fileinput | |
#htpasswd -b htaccess <name> <passwd> | |
count=0 | |
def htaccessimport(file): | |
global count | |
for line in fileinput.input(file): | |
names = line.rsplit(' ') | |
count += 1 | |
try: | |
args = ['htpasswd', '-b', 'htaccess', names[0], names[1]] | |
subprocess.Popen(args) | |
except: | |
print "Failed importing: " + line | |
print "Processed: " + str(count) | |
#you can get the directory by typing 'pwd' into your shell/console | |
htaccessimport("/Users/dekz/Projects/python/accounts.txt") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment