Tuesday, 4 October 2011

How to refresh OBIEE dashboard automatically ?

Here are the steps to set auto refresh for any dashboard in OBIEE, not having any parameters set.

1. Add a text element to the dashboard
2. include the text as shown below, refresh interval in seconds, 900 = 15 Minutes

<META HTTP-EQUIV = "REFRESH" CONTENT = "900">

Wednesday, 28 September 2011

Ways to get sql query output inside UNIX Shell Script


Below are different ways to get SQL query output inside unix shell script.

Method 1:
{
/bin/echo "set pause off"
/bin/echo "set pagesize 0"
/bin/echo "set linesize 300"
/bin/echo "set feedback off"
/bin/echo "set echo off"
/bin/echo "set term off"
/bin/echo "SELECT location_id
FROM location
WHERE facility_id = 'W1';"
} | sqlplus -s dbuser/dbpwd


Method 2: 

Please note that ENDSQL is not a key word, you can use any word.

sqlplus -s dbuser/dbpwd << ENDSQL 
set pause off 
set pagesize 0 
set linesize 300 
set feedback off 
set echo off 
set term off 
select location_id from location where facility_id='W1' and rownum < 2; 
EXIT; 
ENDSQL 

Method 3: 

sqlplus -s dbuser/dbpwd << ENDSQL
set pause off
set pagesize 0
set linesize 300
set feedback off
set echo off
set term off
@filename.sql
EXIT;
ENDSQL

Associated Array in awk


Note that in awk, index can be string instead of traditional integer.
It is great and helpful feature of awk

Just to demonstrate, you can execute below one liner to get the total file size by user.
code to print total file size by users
 > ls -lR | awk '{users[$3]+=$5;} END { for (user in users) { print user, users[user] } }'

To remove ^M in a file while editing it in vi Editor


To remove ^M in a file while editing it in vi Editor 


:%s/^M//g


to type ^M use following key sequences [ ctrl+v and ctrl+m]


alternatively, you can use below perl script to remove ^M characters from multiple files



find . -name '*.txt' |xargs perl -pi -e 's/find/replace/g'

Frequently used UNIX vi commands

frequently used UNIX  vi commands, sharing from Google docs.


Click here to open the spreadsheet.

Saturday, 17 September 2011

Match exact word in a file using grep command

Below command results with multiple records
$ grep VAR8 TAB.SEQ
VAR8        NAVY                          1
VAR80       MISS TURQUOISE                1
VAR81       DUCALE ORANGE                 1
VAR82       EXOTIC GREEN                  1
VAR83       MIMOSE/CORAL RED/CHLOROPHYLLE 1
VAR84       BLACK/NAVY                    1
VAR85       SAND/CLOUD                    1
VAR86       SALMON                        1
VAR87       WHITE/SAND                    1
VAR88       GRAY/WHITE                    1
VAR89       CHARCOAL                      1


Where as, below command matches exact word 
$ grep -w VAR8 TAB.SEQ
VAR8        NAVY                          1

Wednesday, 14 September 2011

How to bring a Background job to Foreground ?

Below command is to get the list of jobs
jobs -l
Below command is to bring the background job to foreground
fg %jobnumber
Mistakenly if you press Ctrl+zz instead of Shft+zz to save a file from vi editor,
You will come out from vi editor with following  message.
[1] + Stopped (SIGTSTP) vi yourfilename
Current vi process will be moved to background mode, you can use below command to get into vi editor again.
fg %jobnumberofviprocess 


Tuesday, 13 September 2011

What is inode??

inode represents any file/directory residing in unix system with a numner known as inode number. It is unique for every file/dir. It is basically a reference that kernel use for any work related to that entity. "ls -i filename" will give you the inode number of that particular file.   ­­  

Sunday, 11 September 2011

TEE Command is beautiful


$ ls –l | tee dir.txt ## list as well as store in a file
total 141 
-rwxrwxrwx 1 mjb group 16850 Apr 12 16:13 SMALL01.DOC 
-rwxrwxrwx 1 mjb group 14881 Apr 12 20:51 SMALL02.DOC 
-rwxrwxrwx 1 mjb group 17758 Jun 13 01:29 Small03.doc 


$ cat dir.txt 
total 141 
-rwxrwxrwx 1 mjb group 16850 Apr 12 16:13 SMALL01.DOC 
-rwxrwxrwx 1 mjb group 14881 Apr 12 20:51 SMALL02.DOC 
-rwxrwxrwx 1 mjb group 17758 Jun 13 01:29 Small03.doc 


## -a switch to append to existing file
echo "Those are all the files“ | tee -a dir.txt 

Use quotes and curly brackets if needed


~ $ ls tmp/
a b
~ $ VAR="tmp/*"
~ $ echo $VAR #surprisingly got directory echoed
tmp/a tmp/b

$ echo "$VAR"
tmp/*
~ $ echo $VARa

~ $ echo "$VARa“

~ $ echo "${VAR}a" #Good Practice
?tmp/*a
~ $ echo ${VAR}a
?tmp/a  

Combine your UNIX commands with control operators


Run a command only if another command returns a zero exit status,

Below command is to change to the directory tmp/a/b/c and list the directory content.
~ $ cd tmp/a/b/c && ls -ltr
Execute second only if first returns non-zero, change to the directory tmp/a/b/c, and if does not exist, create the directory tree and list the content
~ $ cd tmp/a/b/c || mkdir -p tmp/a/b/c && ls -ltr

Another example,

~ $ cd tmp/a/b/c || mkdir -p tmp/a/b/c && touch myfile.txt

Make UNIX directory trees in a single swipe


Defining directory trees individually [BAD Practice]
Create tmp/a/b/c
~ $ mkdir tmp
~ $ cd tmp
~/tmp $ mkdir a
~/tmp $ cd a
 ~/tmp/a $ mkdir b
~/tmp/a $ cd b
~/tmp/a/b/ $ mkdir c
~/tmp/a/b/ $ cd c
          ~/tmp/a/b/c $

Defining directory trees with one command [good Practice]
~ $ mkdir -p tmp/a/b/c

Another example,              
~ $ mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}

What does UNIX stand for?


UNiplexed Information and Computing System.  
(It was originally spelled "Unics.")