Solved

Disable "Ctrl+C"

Posted on 2006-06-19
3
374 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Doing a DR (Disaster Recovery) Test on Red Hat Linux Servers. 2 115
Sed question 2 85
awk sed 8 42
Field name with special character (Ñ) in Oracle 11 50
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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.

778 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