Shell-trap-lock terminal screen, shell-trap-lock Terminal

Source: Internet
Author: User

Shell-trap-lock terminal screen, shell-trap-lock Terminal

Shell-trap-lock terminal screen

#! /Bin/bash # lock the terminal # Shield the termination signal, press ctrl + c to execute the lock_nice function trap "lock_nice" 2 3 15 # The Anti-quotation mark TTY = 'tty 'lock _ nice () on the tab key () {echo-e "\ r Nice. lock nice. the terminal stays locked! \ R "} SAVEDSTTY = 'stty-G' # do not display the input character stty-echoecho-n-e" Enter you passwd to lock $ TTY: "read PASSWDecho-e" \ r "while: do # read form tty only !! Echo-e-n "input passwd for unlock:" read RESPONSE <$ TTY echo-e "\ r" if ["$ RESPONSE" = "$ PASSWD"]; then echo "unlocking... "breakfi # wrong passwd. return lock_nice echo-e "wrong passwd and terminal is locked! \ R "done # display stty $ SAVEDSTTY in terminal readable format

You can also set a password.

#! /Bin/bash # lock the terminaltrap "lock_nice" 2 3 15TTY = 'tty 'lock _ nice () {echo-e "\ r Nice. lock nice. the terminal stays locked! \ R "} SAVEDSTTY = 'stty-G' PASSWD = qwewhile: do # read form tty only !! Echo-e-n "input passwd for unlock:" read RESPONSE <$ TTY echo-e "\ r" if ["$ RESPONSE" = "$ PASSWD"]; then echo "unlocking... "breakfi # wrong passwd. return lock_nice echo-e "wrong passwd and terminal is locked! \ R "done # display stty $ SAVEDSTTY in terminal readable format

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.