Shelll scripts, common script topics.

Source: Internet
Author: User

[Email protected] wyb]#Cat2quan.SH #!/bin/bash# Write a script, first asked to enter a user name, and then let him enter a number, lose if it is a number to output yes, not a number, output no# and then if you enter more than three times is not the number lock this user, is not let him on the # requirements cumulative, even if the script and restart, it is useless, Still locked, the number of times to 3 lock Read_user () {Read-P"Please Input a Username:"Username}read_user while[ -Z $username] DoRead_user Done[ ! -F $username. log] &&Touch$username. Logjudge_user () {Key=`Cat$username. log|WC-l ' [$key-ge3] &&Echo "This $username is lock"&&Exit}judge_userEcho 'input ' quit ' to quit' while : DoJudge_user Read-P"pleas input a number:"Num [-Z $num] &&continue [["$num"="quit"]] && BreakExpr$num +1&>/dev/NULL  [ $? -ne0] &&EchoError >> $username. Log &&Echono| |EchoYes Done[email protected] wyb]# bash 2quan.SHPlease input a username:chenginput ' quit ' to quitpleas input a number:eeenopleas input a number:123Yespleas Input a number:123Yespleas Input A number:dddnopleas input a number:aaanothis Cheng is lock[[email protected] wyb]# bash 2quan.SHPlease Input a username:chengthis Cheng is lock[[email protected] wyb]# bash 2quan.SHPlease input a username:jinginput ' quit ' to Quitpleas input a number:123Yespleas Input A number:bbbnopleas input a number:dddnopleas input a number:aaanothis Jing is lock[[email protected] W yb]# bash 2quan.SHPlease input a username:quitinput ' quit ' to quitpleas input a number:quit[[email protected] wyb]#Catjing.log errorerrorerror[[email protected] wyb]#Catcheng.log errorerrorerror[[email protected] wyb]#

Shelll scripts, common script topics.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.