MISC – May 15th, 2014

I think it might be a good idea to note down the misc tips during daily work. 🙂

1# On ODI 11g, snp_user stores table for user. It provides a tool odi/oracledi/agent/bin/encode.sh to generate encoded password.  SNP_POP table contains the interfaces info and it has a column pointing to FIRST_USER.

2# to_char(sysdate, ‘DD-Mon-YY’) can help generated sysdate in the format of DD-MM-YY.

3# bash sets $UID to the Unix uid it’s running under, and won’t allow it to be changed or the variable to be used for anything else

(luhuang) luhuang- cat test1.sh
(luhuang) luhuang- sh test1.sh
test1.sh: line 1: UID: readonly variable
(luhuang) luhuang-

4# [[ command, performing regexp matching is for bash-only. For tcsh or the other shells,

(luhuang) luhuang- echo $0
(luhuang) luhuang- cat test1.sh
if [[ “$dbs” =~ “no rows selected” ]]; then
printf “xxxx… \n”;
(luhuang) luhuang- sh test1.sh
test1.sh: line 2: conditional binary operator expected
test1.sh: line 2: syntax error near `=~’
test1.sh: line 2: `if [[ “$dbs” =~ “no rows selected” ]]; then’
(luhuang) luhuang-

The more portable version here is,

if echo $dbs | grep “no rows selected”
printf “xxxx. \n”;
exit 1;

5# How to convert a string to uppercase in shell.
printf “Enter YID (e.g: LUHUANG): ”
read YID
YID=`echo $YID | tr ‘[a-z]’ ‘[A-Z]’`