This tutorial will show you how to create a program that can be called to terminate the existing program.
Reason To Use
As you may very well know, terminating using CTRL+T is an easy way to stop startup programs and for hackers to get into the rest of the programs on the computer. One way to stop that is to use the os.pullEvent = os.pullEventRaw in your code, but this could be a problem if you need to run the program for a test, and need to do maintenance on it! Here is a simple solution to your problem.
Here is the code. If you are on a single player world, you can just put this into any existing program by going to /.minecraft/saves/[worldname]/computer/[computernumber]/[programname] and editing it with notepad or notepad++. If you are doing this on a server, and you have access to the server's files, make a program, and go to /[serverdirectory]/[worldname]/computer/[computernumber]/[programname] and copy the code over it. Else, this will need to be typed directly into the console. Now onto the code.
Here is how you could lock the program:
-- Every safe protection locks the terminate key combo. -- Just in case, we will keep what it used to be: local old_pullEvent = os.pullEvent -- And set it to the same as the one used for locking: os.pullEvent = os.pullEventRaw -- Right here is where you set the console input and password. -- Some special keys don't work in ComputerCraft so be careful what you put in it. local code = "terminate" -- This sets the required console input to: terminate local password = "password" -- This sets the password to: password (the one in quotes) -- We want to loop until the correct password is entered while(true) do -- Clear the terminal screen term.clear() -- Set the position of the next terminal output to the top left term.setCursorPos(1,1) -- Send to the screen a prompt that gives a hint of what is going on write("Console: ") -- Purely optional but worth the effort -- Reads the input from the person at the computer local input = read() -- Check if they put in the correct info if input == code then -- Send to the screen a prompt that gives a hint that the password is needed write("Password: ") -- Read from the keyboard and show *s on the screen. -- Don't worry, it just hides it from prying eyes. local input2 = read("*") -- If they entered the correct password if input2 == password then -- End the loop break end -- If we get here, the password was wrong. print("Wrong password. Please try again.") -- Wait a bit so they see the previous line sleep(2) else -- If we got here, the first prompt was given a wrong answer print("Unknown command. Please try again.") -- Wait a bit so they see the previous line sleep(2) end end -- Once the code ends the loop with the ' break ' line, we end up here. -- You can do three things from here: -- 1. End with nothing at the end, -- 2. Use ' error() ' (no 's of course) to go back to the terminal, or -- 3. Call a program after the correct password is entered. -- -- If you do any of the above it is recommended to set -- the os.pullEvent back to the way it was before doing so -- unless you are wanting to not be able to use the -- terminate feature for a run-away program you are testing. -- (You set it to something, right?) os.pullEvent = old_pullEvent