Search This Blog

Thursday, March 27, 2014

Script to Disable Cntrl+C on unix box



Some of the examples using trap is already discussed in a separate post where numeric notation is used for different signals.

Below are the standard examples by which we can come to know the importance of trap in our day to day scenarios.

To disable the activity of Cntrl + C ...

trap "echo 'cntrl c is disabled'" INT

This can be placed in .profile or .login accordingly.

Script:

I tried this simple script to ignore cntrl signals like ctrl c and ctrl d

TrapCase()
{
echo "entered cntrl char"
Original Function
}

OriginalFunction()
{
echo "enter input"
trap 'TrapCase' 1 2 15
read value
echo "This is after trap is executed"
echo $value
}

#Calling basic function
OriginalFunction


No comments:

Post a Comment