Page 1 of 2

Firing query on UNIVERSE through UNIX script

Posted: Sun Jun 03, 2012 3:25 am
by shobhit_vk_gupta
Hi Folks,

Please help me with one issue. I want to know how to execute a query on DS_JOBS through UNIX script.

I know the steps like:
1)LOGTO Project_name
2)Write a query: SELECT COUNT(*) FROM DS_JOBS

But I need to automate this process through UNIX script.

Please suggest.

Posted: Sun Jun 03, 2012 4:48 am
by zulfi123786
as simple as having the below two commands in your script

Code: Select all

cd "Project directory"
dssh " select * from DS_JOBS ; "

however if you let us know what is your actual intension by querying the repository, you might get a better suggestion

Posted: Tue Jun 05, 2012 5:44 am
by shobhit_vk_gupta
Hi Zulfi,

Thanks for your reply.

I have tried this but it is not working.

I will give you one example:

Whenever we have find out the job number of a job , we either fire a query on administrator or do the same through command prompt.

We care doing this through command prompt by just following the below mentioned steps:

1)Go to DSEngine directory
2)fire: . ./dsenv
3)bin/uvsh
4)LOGTO Project_Name
5)fire query: SELECT JOBNO FROM DS_JOBS WHERE NAME='JobName';

The output of the above query is the Job number.

This I am doing manually now but I want to automate this process.
I am finding difficulty from step number 3.

I need to execute the LOGTO and SELECT command on UNIVERSE.

I have tried below mentioned command but it doesn't work:

bin/uvsh < "LOGTO Project_Name";
bin/uvsh < "SELECT * FROM DS_JOBS";

Some how I need to pass step 4 and step 5 command to the UNIVERSE through unix command line.

I hope you have understood my question.

Posted: Tue Jun 05, 2012 6:35 am
by chulett
As noted, if you 'cd' to the Project directory in question, you don't need the LOGTO. Otherwise, just do both commands in the same dssh session with a proper delimiter between them. Semi-colon?

Posted: Tue Jun 05, 2012 7:45 am
by shobhit_vk_gupta
Thanks for your reply.

When I execute "dssh" in Project directory, I get following error:

"bash: dssh: command not found"

What could be the reason?

Posted: Tue Jun 05, 2012 9:05 am
by chulett
Because it couldn't find it. :wink:

That directory is not in your $PATH. Either add it or fully path dssh so it knows where it lives.

Posted: Tue Jun 05, 2012 10:52 am
by vamsi.4a6
if you want no of jobs in a project u can use below command


dsjob -ljobs projectname|wc -l

Posted: Tue Jun 05, 2012 10:57 am
by vamsi.4a6
chulett wrote:As noted, if you 'cd' to the Project directory in question, you don't need the LOGTO. Otherwise, just do both commands in the same dssh session with a proper delimiter between them. Semi-colon ...
Could u please clarify below points

where i need to mention 'cd' to the Project directory i mean after 1 or 2 step etc ?

1)Go to DSEngine directory
2)fire: . ./dsenv
3)bin/uvsh
4)LOGTO Project_Name
5)fire query: SELECT JOBNO FROM DS_JOBS WHERE NAME='JobName'

2)could you Please elaborate on the below point

Just do both commands in the same dssh session with a proper delimiter between them

Posted: Tue Jun 05, 2012 1:31 pm
by chulett
1) As step 2.5 then fully path step 3.

2) One dssh call that runs all steps one after the other, all in the same 'session'.

Posted: Wed Jun 06, 2012 12:06 am
by shobhit_vk_gupta
Hi Vamsi,

Thanks for your participation.
Actually my requirement is not to find out total number of jobs in a project, but it is to find out the job number which is associated with a Job.


Chulett,

I have tried to find out the path where dssh might be stored but as displayed below it is not present.

bash-2.05b$
bash-2.05b$ whereis dssh
dssh:
bash-2.05b$

Posted: Wed Jun 06, 2012 12:28 am
by shobhit_vk_gupta
Hi Team,

I have found out one more thing. This might help.

I went into the bin directory of DSEngine.

Please find the directory structure, you can find dssh:

-rwxr-x--x 1 twdsadmp twdsadmp 1379 Oct 14 2008 pi.t1conv
-rwxr-x--x 1 twdsadmp twdsadmp 3265 Oct 14 2008 pi.prepisys
-rwxr-x--x 1 twdsadmp twdsadmp 8330 Oct 14 2008 pi.cvtacc
-rwxr-xr-x 1 twdsadmp twdsadmp 101349 Nov 3 2008 dssearch
lrwxrwxrwx 1 root system 56 Mar 31 2009 dssh -> /tahtidsdatap/InformationServer/Server/DSEngine/bin/uvsh
-rwsr-x--x 1 root system 1763689 Mar 31 2009 load_NLS_shm
-rwxr-xr-x 1 twdsadmp twdsadmp 2201577 Dec 3 2009 nbasic
-rwxr-xr-x 1 twdsadmp twdsadmp 40520 Dec 3 2009 dsrpcd
-rwxr-xr-x 1 twdsadmp twdsadmp 1793465 Dec 3 2009 shmtest

Here, when I try to execute dssh, it displays following statement:

This directory is not set up for DataStage.
Would you like to set it up (Y/N)?

Posted: Wed Jun 06, 2012 12:33 am
by zulfi123786
dssh should ideally be in the bin directory of DSEngine

Posted: Wed Jun 06, 2012 12:35 am
by zulfi123786
shobhit_vk_gupta wrote:This directory is not set up for DataStage.
Would you like to set it up (Y/N)?
you can avoid this by invoking dssh from you project directory

Posted: Wed Jun 06, 2012 12:36 am
by shobhit_vk_gupta
zulfi123786 wrote:dssh should ideally be in the bin directory of DSEngine
yes zulfi

It is in BIN directory but it is a softlink which is pointing to ....DSEngine/bin/uvsh

Posted: Wed Jun 06, 2012 2:38 am
by ray.wurlod
It doesn't matter what it's a link to. It's there.

Always answer "Would you like to set it up?" in the negative.

Code: Select all

cd $ProjectDir
DSHOME=`cat /.dshome`
export DSHOME
$DSHOME/bin/dssh "SELECT COUNT(*) FROM DS_JOBS;"