Bash:db2top

From PIT (Practical IT) Wiki
Jump to navigation Jump to search

How to create a bash script to get db2top running and in color mode.

You should know about the current LANG and LC_ALL definitions

Your TERM value should be "xterm", if it is not set, please set this value in db2inst environment before starting to build d+the script.

First action is to check LANG and LC variables (and don't forget to note the LANG value for later need).

set | egrep 'LC_|LANG'

Make note of the LANG value and the LC_ALL value.

This example is based on initial values "EN_US.UTF-8"


Set LC_ and LANG values for db2top needs:

LC_COLLATE="C"

LC_CTYPE="C"

LC_MONETARY="C"

LC_NUMERIC="C"

LC_TIME="C"

LC_MESSAGES="C"

LC_ALL=

LANG=en_US

and check again:

set | egrep 'LC_|LANG'

call db2top with db name as argument 1 (if you are successful you will see a db2top screen in full color mode)

db2top -d $1

after db2top execution reset all variables to initial value

unset LC_COLLATE

unset LC_CTYPE

unset LC_MONETARY

unset LC_NUMERIC

unset LC_TIME

unset LC_MESSAGES

LC_ALL=EN_US.UTF-8

LANG=EN_US.UTF-8

LC__FASTMSG=true

LC_ALL and LANG should contain the values as noted above ! and check again:

set | egrep 'LC_|LANG'

the screen will need some tidy-up, so maybe you should clear it:

clear


Initial values may vary, so please keep in mind to restore all initial values that you changed before calling db2top.