Firing query on UNIVERSE through UNIX script

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

shobhit_vk_gupta
Participant
Posts: 14
Joined: Wed May 05, 2010 1:24 am

Firing query on UNIVERSE through UNIX script

Post 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.
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post 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
- Zulfi
shobhit_vk_gupta
Participant
Posts: 14
Joined: Wed May 05, 2010 1:24 am

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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?
-craig

"You can never have too many knives" -- Logan Nine Fingers
shobhit_vk_gupta
Participant
Posts: 14
Joined: Wed May 05, 2010 1:24 am

Post 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?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post by vamsi.4a6 »

if you want no of jobs in a project u can use below command


dsjob -ljobs projectname|wc -l
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
shobhit_vk_gupta
Participant
Posts: 14
Joined: Wed May 05, 2010 1:24 am

Post 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$
shobhit_vk_gupta
Participant
Posts: 14
Joined: Wed May 05, 2010 1:24 am

Post 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)?
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

dssh should ideally be in the bin directory of DSEngine
- Zulfi
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post 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
- Zulfi
shobhit_vk_gupta
Participant
Posts: 14
Joined: Wed May 05, 2010 1:24 am

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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;"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply