图片介绍:松金洋子,著名美女模特。
正文:
//2011-12-23符号修改 useradd -g ftp -d /media/ftprootpath/${bb[*]}
当年有台ftp服务器挂了,然后要用另台拿来顶用,但是有上百个用户,一个一个创建明显不太靠谱,当初是峰哥搞的,我也不知道是咋弄的,后来才知道。开始我还以为是修改/etc/passwd文件呢。
[root@testcms sh]# cat li.sh
!/bin/bash
aa=(q w e r t)
pp=(a s d f g)
for i in ${aa[*]}
do
useradd $i
echo ${pp[*]} | passwd --stdin $i
done
[root@testcms sh]#
[root@testcms sh]# sh li.sh
li.sh: line 1: !/bin/bash: No such file or directory
Changing password for user q.
passwd: all authentication tokens updated successfully.
Changing password for user w.
passwd: all authentication tokens updated successfully.
Changing password for user e.
passwd: all authentication tokens updated successfully.
Changing password for user r.
passwd: all authentication tokens updated successfully.
Changing password for user t.
passwd: all authentication tokens updated successfully
[root@testcms sh]#
[root@testcms sh]# cat /etc/passwd
q:x:514:514::/home/q:/bin/bash
w:x:515:515::/home/w:/bin/bash
e:x:516:516::/home/e:/bin/bash
r:x:517:517::/home/r:/bin/bash
t:x:518:518::/home/t:/bin/bash
[root@testcms sh]# su - q
[q@testcms ~]$
####################################################################################
!/bin/bash
#username
aa=(q w e r t)
#passwd
pp=(a s d f g)
#directory
bb=(m n b v c)
aa1=${#aa[*]}
pp1=${#pp[*]}
bb1=${#[bb[*]]}
#for ((i=1;i<${aa1};i++)) 2012-1-5 符号修改
for ((i=0;i<${aa1};i++))
do
useradd -g ftp -d /media/ftprootpath/${bb[i]} ${aa[i]}
echo ${pp[i]} | passwd --stdin ${aa[i]}
done
####################################################################################
这个主要就是用到三个知识点:
1.数组
2.for
3.passwd --stdin
阅读(1269) | 评论(1) | 转发(0) |