Start password for Shell application programming. Welcome to welcome.

Source: Internet
Author: User

Start password for Shell application programming. Welcome to welcome.

Description: If you want to lock access to the terminal but do not want to exit and log on again, you can write a script.Program.

When the script is called, you can exit only after you have entered the correct password.

Where:CTRL + u Delete the entire row

CTRL + B Delete the previous character

Characters in bold

Shell Process source sequence:

Trap "" 2 3 4 stty-echo # tput belstty kill \ ^ ustty erase \ ^ btput bold # tput blinktput Bel # tput dimif [$ #-GT 0] Then mesg = "$ @ "else mesg =" this system is locked "fitput cleartput cup 5 10; echo "Enter your passwd> \ c" read pword_1tput cleartput Cup 10 20; echo "$ mesg" pword_2 = until ["$ pword_1" = "$ pword_2"] Do tput rev read pword_2donestty echotput clearexit 0

Analysis: capture the signal through trap, and set the interrupt signal and exit signal to be blocked. That is, the CTRL + C, Del, and break keys do not work.

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.