Mask's web site

 

作品集 | 大學回憶 | 我的家庭
我的最愛 > FreeBSD > Adduser
   
  • Step 1
    #!/usr/bin/perl
    open(PASSWD,"list") || die "Can't open the file:list\n";
    $uid=2000; #the first uid
    while (<PASSWD>)
    {
    chop;
    @F = split(/ /,$_);
    $crypt_pwd = crypt( $F[1] ,"" );
    system("mkdir /home/$F[0]");
    system("chmod 700 /home/$F[0]");
    print "$F[0]:$crypt_pwd:$uid:0::0:0:$F[0]:/home/$F[0]:/bin/tcsh\n";
    $uid++;
    }
    close(PASSWD);
  • Step 2
    #!/usr/bin/perl
    system("pwd_mkdb /etc/master.passwd");
    open(CHOWN_USER,"list");
    while (<CHOWN_USER>)
    {
    chop;
    @E = split(/ /,$_);
    system("chown $E[0] /home/$E[0]");
    }
    close(CHOWN_USER);
  • Step 3
    # perl au1 >> /etc/master.passwd
    # perl au2

 

© by rex from 2001/7.
All rights reserved.