add more users

#!/bin/bash

# addclass ga 1 50  username ga0101-ga0150

groupadd users 2>> /dev/null
if [ $? -eq 0 ]
then
echo "Users is created seccussfully !"
else
echo "Users is exist,you needn't created !"
fi
grade=$1
num_class=`expr $2 + 0`

if (test $num_class -le 9)
    then
num_class="0"$num_class
fi

max_stid=`expr $3 + 0`
num_stid=1

if [ ! -x /home/student ]
then
mkdir /home/student
fi

if [ ! -x /home/student/$1$num_class ]
then
mkdir /home/student/$1$num_class
fi

while (test $num_stid -le $max_stid)
do
if (test $num_stid -le 9)
then
num_stid="0"$num_stid
fi
user_name=$grade$num_class$num_stid
echo $user_name":"$user_name >> user_pwlist
adduser -g users -d /home/student/$1$num_class/$user_name $user_name
#setquota -u $user_name 10240 20480 0 0 /home
chmod 755 /home/student/$1$num_class/$user_name
num_stid=`expr $num_stid + 1`
done

chpasswd < user_pwlist
pwconv
/bin/rm -f  user_pwlist

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Also create a ControllerCreate class that extends Controller.The create method takes as arguments the name of a new library user, a number of books (as a string), and an integer representing the role of user to create (where the integer 0 means a lender and the integer 1 means a borrower). The create method of the controller then transforms the book number from a string to an integer (using the Integer.parseInt static method), creates an object from the correct class (based on the role specified by the user input: lender or borrower) and calls the addUser method of the library to add the new user object to the library. • If no exception occurs then the create method of the controller returns the empty string. • If the constructor of the Borrower class throws a NotALenderException then the create method of the controller must catch this exception and return as result the error message from the exception object. • If the parseInt method of the Integer class throws a NumberFormatException (because the user typed something which is not an integer) then the create method of the controller must catch this exception and return as result the error message from the exception object. Modify the run method of the GUI class to add a ViewCreate view that uses a ControllerCreate controller and the same model as before (not a new model!) Do not delete the previous views. Note: if at the end of Question 7 you had manually added to your library (model object) some users for testing, then you must now remove those users from the run method of the anonymous class inside the GUI class. You do not need these test users anymore because you have now a graphical user interface to create new users! Run your GUI and check that you can correctly use the new view to create different users for your library, with different types of roles. • Check that, when you create a new user, the simple view is automatically correctly updated to show the new total number of books borrowed by all users. • Also use the “get book” view to check that the users are correctly created with the correct names and correct number of books. • Also check that trying to create a borrower with a negative number of books correctly shows an error message. Also check that trying to create a user with a number of books which is not an integer correctly shows an error message (do not worry about the content of the error message). After you created a new user, you can also check whether it is a lender or a borrower using the “more book” view to increase the number of books of the user by a big negative number: • if the new user you created is a lender, then increasing the number of books by a big negative value will work and the number of books borrowed by the user will just become a larger value (you can then check that using the “get book” view); • if the new user you created is a borrower, then increasing the number of books by a big negative value will fail with an error message and the number of books borrowed by the user will not change (you can then check that using the “get book” view). 完成符合以上要求的java代码
05-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值