Solved

Disable "Ctrl+C"

Posted on 2006-06-19
3
369 Views
Last Modified: 2010-04-21
Dear All,

Can I prevent the user from terminating the program by pressing "Ctrl+C" after running the script developed by me?

Please advise.
I am using Sun Solaris 8 & ksh.

Thanks.
0
Comment
Question by:iecu
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
tfewster earned 125 total points
ID: 16940132
Yes, using the shell built-in comand `trap`, e.g.
trap 'echo "Ctrl-C disabled" ' 0 1 2 3

For more examples, please see
http://www.experts-exchange.com/Developer/Operating_Systems/Solaris/Q_20311700.html
http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_10074403.html


0
 
LVL 48

Expert Comment

by:Tintin
ID: 16956566
or to disable completely, add

stty intr ''

in the user's .profile

0
 
LVL 48

Expert Comment

by:Tintin
ID: 16997233
trap 'echo "Ctrl-C disabled" ' 0 1 2 3

is more accurately written

trap 'echo "SIGINT is trapped, which may or may not be Ctrl-C"' 2
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now