标签:面试 std plist index lis false ping server ber
#!/bin/sh for n in `seq 254` do ping -c1 -w1 10.0.0.$n &>/dev/null if [ $? -eq 0 ] then echo "10.0.0.$n is up ">>/tmp/uplist.log else echo "10.0.0.$n is down ">>/tmp/downlist.log fi done
2.批量创建10个系统帐号oldboy01-oldboy10并设置密码(密码为随机8位字符串)。
#! /bin/bash . /etc/init.d/functions Path=/server/scripts UserDb=$Path/user.db FailDb=$Path/fail_user.db [ -d "$Path" ] || mkdir-p $Path [ -f "$UserDb" ] ||touch $UserDb [ -f "$FailDb" ] ||touch $FailDb for n in $(seq -w 10) do passwd=`echo $(date+%t%N)$RANDOM|md5sum|cut -c 2-9` useradd oldboy$n >&/dev/null&& user_status=$? echo "$passwd"|passwd --stdinoldboy$n >&/dev/null && pass_status=$? if [ $user_status -eq 0 -a $pass_status -eq0 ];then action "adduser oldboy$n"/bin/true echo -e "user:\toldboy$npass:$passwd" >>$UserDb else action "adduser oldboy$n"/bin/false echo -e "user:\toldboy$npass:$passwd" >>$FailDb fi done
标签:面试 std plist index lis false ping server ber
原文地址:http://www.cnblogs.com/gala1021/p/7826227.html