shell脚本-从用户列表里批量创建或…
来源:互联网 发布:php trim 编辑:程序博客网 时间:2024/06/06 08:54
#!/bin/bash
#./adduser.sh -a -- userlist
set -- `getopt -q ad $@`
flag=0
while [ -n $1 ]; do
case $1 in
-a|--add)
flag=add
;;
-d|--delete)
flag=del
;;
-h|--help)
echo "Descreption: this script is use to add or delete userfrom file"
echo -e "\t-a|--add\n\t\t add user"
echo -e "\t-d|--delete\n\t\t delete user"
echo -e "\t-h|--help\n\t\t get the helppage"
exit 0
;;
--)
shift
break
;;
*)
echo "error,use -h to get help"
exit 1
;;
esac
shift
done
list=`echo $1 | sed "s/'//g"`
for user in `cat $list`; do
case $flag in
add)
useradd $user
echo "user $user added"
;;
del)
userdel -r $user
echo "user $user deleted"
;;
*)
echo "error"
exit 1
esac
done
阅读全文
1 0
- shell脚本-从用户列表里批量创建或…
- shell脚本-批量添加或删除用户
- Shell脚本_创建系统用户,从一个用户列表文件(6.18重构)。
- shell脚本创建用户及批量创建用户
- Shell脚本批量创建用户并随机生成密码
- shell脚本批量添加用户
- shell脚本批量增加用户
- shell脚本批量操作用户
- Linux shell 批量创建用户
- 用脚本批量创建用户
- shell oracle 创建用户脚本
- shell脚本自动创建用户
- shell脚本 - 自动创建用户
- 批量添加用户shell脚本详解
- shell编程Linux中批量创建用户
- 脚本练习-Script.sh批量创建用户
- 批量创建KVM虚拟机与批量推公钥的shell脚本
- shell脚本创建用户并设置密码
- 系统开机流程
- BIOS与CMOS的区别
- linux 基础知识测试
- 关于启动另一个app的操作
- 逻辑卷创建过程
- shell脚本-从用户列表里批量创建或…
- shell脚本批量添加用户
- shell脚本习题
- 设计模式之装饰模式
- rsync服务器搭建,实现自动化备份
- linux expect自动登录s…
- 用shell脚本批量分发公钥,实现用…
- 搭建nfs共享文件系统并用rsync+ino…
- RC4算法