Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Disable "Ctrl+C"

Posted on 2006-06-19
3
Medium Priority
?
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
tfewster earned 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

688 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