FreeBSD 大量转档建帐号程式(perl代码)

发表于:2007-07-01来源:作者:点击数: 标签:
############## # adduser.pl # ############## #!/usr/bin/perl $filename = @#class.txt@# ; open(file,$filename) ; while( $name= ) { chop $name ; @name_array = split /,/,$name ; $PW_COMMAND="/usr/sbin/pw useradd $name_array[0] -m -h 0" ; $fnam
##############
# adduser.pl #
##############

#!/usr/bin/perl
$filename = @#class.txt@# ;
open(file,$filename) ;
while( $name= ) {
chop $name ;
@name_array = split /,/,$name ;
$PW_COMMAND="/usr/sbin/pw useradd $name_array[0] -m -h 0" ;
$fname="|".$PW_COMMAND ; open(OUT, $fname) ;
print OUT $name_array[1] ;
close(OUT) ;
print "UserName: ",$name_array[0],"\t\t",
"Password: ",$name_array[1],"\n";
}
print "\n" ;
close(file) ;

################
# /etc/pw.conf #
################
logfile /root/pw.log
defaultpasswd yes
home /home
defaultshell /usr/local/bin/bash
defaultgroup user
reuseuids yes
minuid 2000

##############
# 额外说明 #
##############
1.home -->预设的家目录
defaultshell -->预设的shell路径
defaultgroup -->预设的群组
1.minuid -->起始的uid

############
# 使用方式 #
############
1.先备档案
a. adduser.pl
b. /etc/pw.conf
c. 帐号的来源档 class.txt
形式:
帐号,密码
帐号,密码
2.步骤
a.将adduser.pl改为可以执行
chmod 700 adduser.pl
b.adduser.pl及class.txt需在同一目录下,不然则需更改路径
c.执行adduser.pl
d.完成

原文转自:http://www.ltesting.net