linuxtput命令的简单介绍( 二 )


(use "git add file..." to update what will be committed)
(use "git checkout -- file..." to discard changes in working directory)
modified:index.js
Untracked files:
(use "git add file..." to include in what will be committed)
.jshintrc
package.json
test/
NS:tput ns$ git commit -m 'create project tput'
[master b49f84b] create project tput
1 file changed, 33 insertions(+)
create mode 100644 index.js
NS:tput ns$ git push -u origin master
如果你不喜欢使用命令行,那可以使用 github 提供的桌面工具 , 百度知道好像不让发 URL,所以你可以自行百度 github 桌面版,去下载,有 Mac 和 Windows 版本
用shell脚本批量创建30个用户,用户名为exam1~exam30,用户密码统一为gdlclinux 。写好了,还在测试,测试好了就给linuxtput命令你 。
写好了,通过测试了 。
########################################################################
#注:本脚本中使用了函数模块 , 以方便修改和调试
#************************************************
#2011年12月10日 初稿
#************************************************
#2011年12月11日 测试问题:密码修改函数尚未实现
#************************************************
#2011年12月11日 定稿密码修改函数实现
#************************************************
#bybmw88661@126.com12.11.2011
########################################################################
#设置变量
i=1
username=exam
password=gdlclinux
rmso=$(tput rmso)
smso=$(tput smso)
#此处可添加要求输入用户名和密码linuxtput命令的项
#错误判断函数
SEA()
{
location=$( which useradd )#查找useradd的绝对路径
if [ \( "$location" = "" \) -o \( -s "$location" \) ]#判断是否找到useradd文件,或着找到的文件为空
then
echo "Useradd was not found,job terminated $smso unsuccessfully$rmso!"
exit
else
if [ -x "$location" ]#若useradd文件存在且不为空,判断是否具有可执行权限
then
echo "Command useradd doesn't have excution(x) mode"
exit
else#无法确定问题原因
echo "Script terminated by some unknown problem,Please check it!"
exit
fi
fi
}
#提示信息函数
casemsg()
{
#判断passwd执行的返回值,并进入case分支
case "$y" in
0) echo "Set password for $smso $username$i$rmso successfully"
;;
1) echo "Permission denied when set password for $smso $username$i$rmso"
exit 1 ;;
2) echo "Invalid combination of options for command passwd"
exit 2 ;;
3) echo "Unexpected failure, nothing done"
exit 3 ;;
4) echo "Unexpected failure, passwd file missing"
exit 4 ;;
5) echo "Passwd file busy, try again"
exit 5 ;;
6) echo "Invalid argument to option"
exit 6 ;;
esac
}
#用户创建函数
usercreate()
{
useradd -m $username$i#如果需要其他功能,请参照useradd帮助手册修改此行,如:设置uid
x=$?
}
#密码修改函数
#这里如果你的系统里有chpasswd这个批修改工具的话 , 就不用这么麻烦了 。
MOVpassword()
{
( echo "$password";sleep 1;echo "$password" )|passwd $username$i#若useradd执行成功,则调用passwd设置密码
y=$?
}
#主循环
while [ "$i" -ge 1 -a "$i" -le 30 ]
do
usercreate#调用usercreate函数创建用户
if [ "$x" -eq 0 ]#判断useradd是否执行成功
then
echo "User $smso $username$i$rmso have been create successfully!"
MOVpassword#调用MOVpassword修改密码
【linuxtput命令的简单介绍】

推荐阅读