用户自动创建脚本
来源:互联网 发布:plsql导出表数据dmp 编辑:程序博客网 时间:2024/06/05 05:45
1.wc统计行数
[root@localhost mnt]# wc -l username
3 username
[root@localhost mnt]# wc -l username | cut -d ” ” -f 1
3
2.echo $?
上一条命令执行成功显示 0 | 否则显示 1
[root@localhost mnt]# cat usernacat: userna: No such file or directory[root@localhost mnt]# echo $?1[root@localhost mnt]# cat username linux1linux2linux3[root@localhost mnt]# echo $?0[root@localhost mnt]#
#!/bin/bashUSERNUM=`wc -l /mnt/username | cut -d " " -f 1`PASSWDNUM=`wc -l /mnt/password | cut -d " " -f 1`cat /mnt/username >& /dev/nullif [ $? = 0 ]thencat /mnt/password >& /dev/null if [ $? = 0 ] then if [ ${USERNUM} = ${PASSWDNUM} ] then for N in $(seq 1 $USERNUM ) do USERNAME=`sed -n ${N}p /mnt/username` PASSWORD=`sed -n ${N}p /mnt/password` id $USERNAME >& /dev/null if [ $? -ne 0 ] then useradd $USERNAME >& /dev/null echo $PASSWORD | password --stdin $USERNAME >&/dev/null echo "$USERNAME 创建成功" else echo "$USERNAME 已经存在" fi done else echo 用户名字与密码个数不匹配 fi else echo 密码文件不存在 fielse echo 用户文件不存在fi
[root@localhost mnt]# cat password
123
456
789
[root@localhost mnt]# cat username
linux1
linux2
linux3
[root@localhost mnt]# sh jluser.sh
linux1 创建成功
linux2 创建成功
linux3 创建成功
[root@localhost mnt]# vim jluser.sh
[root@localhost mnt]# echo 123 > password
[root@localhost mnt]# cat password
123
[root@localhost mnt]# sh jluser.sh
用户名字与密码个数不匹配
0 0
- 用户自动创建脚本
- linux自动创建用户脚本
- shell脚本自动创建用户
- shell脚本 - 自动创建用户
- Shell脚本: Mysql自动创建库和用户_20160607_七侠镇莫尛貝
- 用户自动建立脚本
- 自动建立用户脚本
- oracle创建用户脚本
- 创建本地用户脚本
- 创建用户脚本
- 创建用户的脚本
- 用户创建脚本
- linux里, 创建用户的过程直接写在脚本里,自动创建
- java获取并编辑用户脚本,创建并自动执行testng.xml文件_03
- shell oracle 创建用户脚本
- 创建linux 用户登录脚本
- 用脚本批量创建用户
- 自动生成创建索引脚本
- jsp乱码问题全解
- LDR指令
- 渗透测试攻防练习实验室 (资源分享,国外在线教程)
- 用变量简化计算
- 解决fatal error: 'ffi.h' file not found
- 用户自动创建脚本
- 数据库MySQL的安装
- java中byte[]、buffer、string转换
- The Linux Programming Interface 11 System Limits And Options 系统限制和选择
- 大数据学习笔记之五十 推荐算法的距离算法和相似度算法
- 初识ajax
- 模拟基础之统计字符串中的英文单词数目
- bitset类简介
- PAT basic 1001