0

I want to change the color scheme to red when someone logs into the prod system. I achieved this by querying our central repository for prod servers and updating .kshrc as below -

host=hostname ... ...

search string using $hostname

env will be set to 1 if the server is prod

if [[ $env = 1 ]] then tput setaf 7 tput setab 1 clear else tput setaf 7 tput setab 4 clear fi

This works fine when I am remote login to prod and then again remote login to another non-prod. But problem is when I for example login to a prod system from a non prod the color scheme changes to red as expected , however, if I use ctrl+d to logout the color scheme doesn't change even though I am now logged out in the non-prod system. Any suggestions, on how SIGQUIT (ctrl+d) can be trapped and used for color change?

1 Answers1

-2

I will try to rephrase my answer since people are getting confused here...

So my suggestion was to use the trap command in order to trap the signal and then do what you want to do. The syntax of the trap command is

trap "command1; command2; command3" signal1 signal2 (you can trap more signals in the same line)

If trapping SIGQUIT doesn't work please check if your terminal indeed sends SIGQUIT on Ctrl+d

Some links that can be helpful are:

http://www.tutorialspoint.com/unix/unix-signals-traps.htm

http://www.ibm.com/developerworks/aix/library/au-usingtraps/

http://linuxcommand.org/wss0160.php

Ionut
  • 476
  • 1
  • 3
  • 12