[root@master1-192-168-117-18 ~]# vim users.txt
目前創(chuàng)新互聯(lián)已為上千余家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)站空間、成都網(wǎng)站托管、企業(yè)網(wǎng)站設(shè)計(jì)、甘肅網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
[root@master1-192-168-117-18 ~]# vim Example.sh
#!/bin/bash
read -p "Enter The Users Password:" PASSWD
for UNAME in cat users.txt
do
id $UNAME &> /dev/null
if [ $? -eq 0 ]
then echo "Already exits"
else useradd $UNAME &> /dev/null
echo "$PASSWD" | passwd --stdin $UNAME &> /dev/null
if [ $? -eq 0 ]
then echo "$UNAME,create success!"
else echo "$UNAME,Create failure!"
fi
fi
done
[root@master1-192-168-117-18 ~]# bash Example.sh
Enter The Users Password:1234
zhangsan,create success!
lisi,create success!
wangmazi,create success!
hanmeimei,create success!
lilei,create success!
bobo,create success!
[root@master1-192-168-117-18 ~]# vim ChechHosts.sh
#!/bin/bash
HLIST=$(cat ~/ipadds.txt) #$(可執(zhí)行命令)=·可執(zhí)行命令·
for IP in $HLIST
do
ping -c 3 -i 0.2 -W $IP &> /dev/null
if [ $? -eq 0 ];then
echo"Host $IP is on-line."
else
echo"Host $IP is off-line."
fi
done