cdolinux命令 cd命令 linux

linux shell脚本用到循环、控制语句#!/bin/sh
# Name: useraddmuti
# Descripton: To add users to your system. Users can be list in a file.
#To exec this command your ID must be 0.
# Author: PopZslam@Linux.net
#-----------------------------------
chkUID(){
getUID(){
id|sed -e 's/(.*$//' -e 's/^uid=//'
}
if [ "`getUID`" -ne 0 ]
then
echo -e "\tYou are not root!"
exit 0
fi
}
chkUID
usagePRT(){
echo ${USAGE:='USAGE:' `basename $0` '-f namelistfile'}
}
chkFILE(){
if [ ! -z "`awk 'NF!=2{print NF;exit;}' $1`" ][ "`awk 'NF!=2{print NF;exit;}' $1`" -ne 2 ] ; then
echo -e "The file's format is not right!"
exit 0
fi
}
userCHK(){
for USER in `awk '{print $1;}' $1`
do
if grep -wq $USER /etc/passwd ; then
echo -e "The user($USER) has been added!"
exit 1
fi
if echo $USER|grep -wq "^[0-9].*" ; then
echo -e "The user($USER)'s name is wrong format!"
exit 1
fi
done
}
setOPT(){
echo -e "Now Let's set some options or you can use default settings."
setGRPNAME(){
while :
do
echo -e "Would you like to add a new group to add these users to it?"
echo -e "Enter YES to create a new group otherwise you must verify the group."
printf "Your Answer: "
read grpopt
case $grpopt in
yes)
printf "Please enter the group's name: "
read grpoptnew
if cat /etc/group|sed 's/:.*//'|grep -wq $grpoptnew ; then
echo "The group's name($grpoptnew) exist."
exit
else
grpname=$grpoptnew
echo -e "All these users will be added to group($grpname)..."
echo -e "Adding group ..."
if cp /etc/group /etc/group.$$ ; /dev/null 2;1 ; then
if groupadd $grpname ; then
echo -e "The group($grpname) is added!"
rm -f /etc/group.$$
break 1
else
echo -e "There's something wrong when adding the group($grpname)."
echo -e " *** Please recovered the group file. *** "
echo -e "You can cp /etc/group.$$ to /etc/group to recover."
fi
else
echo "Error! Please check the program or your disk space."
exit 0
fi
fi
;;
*) : ;;
esac
done
}
setGRPNAME
}
addUSER(){
if cp /etc/passwd /etc/passwd.$$cp /etc/shadow /etc/shadow.$$ ; then
for user in `sed 's/ .*//' $1`
do
pass=`awk '{
$1~/$name/
{print $2;exit}
} name=$user' $1`
if [ -z "$pass" ] ; then
echo -e "The passwd is used by default sun123."
pass=sun123
fi
if [ ${#pass} -lt 6 ] ; then
echo -e "The user($user)'s password is too short!"
echo -e "Use default password: sun123."
pass=sun123
fi
if useradd $user ; then
echo -e "The user($user) is added."
if echo $pass|passwd $user --stdin ; /dev/null 2;1 ; then
echo -e "The user($user)'s password is setted!"
else
echo -e "The user($user)'s password is NOT set!"
fi
else
echo -e "The user($user) is NOT add."
fi
done
rm -f /etc/passwd.$$ /etc/shadow.$$
else
echo -e "There something wrong when backup the passwd and shadow file."
fi
}
if [ $# -ne 2 ] ;then
usagePRT
exit 0
fi
case "$1" in
-f)
if [ -f "$2" ] ; then
echo -e "Reading usernamelist file""("$2")" "..."
chkFILE $2
userCHK $2
setOPT
addUSER $2
else
echo -e "There's no usernamelist file!"
fi
;;
*) usagePRT
exit 0
;;
esac
"0x003b3c20"指令引用“0x003b3c20"内存,该内存不能为“read”如果偶尔出一次 就不用管他 如果出的频繁最好的办法就是重做系统
使用Windows操作系统的人有时会遇到这样的错误信息:“0X????????指令引用的0x00000000内存,该内存不能written”,然后应用程序被关闭 。其实,这个错误并不一定是Windows不稳定造成的 。本文就来简单分析这种错误的常见原因 。

推荐阅读