Page 1 of 1

How to run several dssh scripts in one batch

Posted: Wed Sep 09, 2009 5:35 am
by hailun
Hi,
I would like to realize one function retrieving the hash_num for one job using shellscript,the server is of AIX

What I do now in the script file is
'hellp' is project name and 'Test' is the job name

dssh<<eof
logto hellp
select JOBNO FROM DS_JOBS WHERE NAME ='Test'
quit
eof

But it will take long time to run and return no record,
BTW I type the command as following
dssh<<eof
>logto hellp
>SELECT JOBNO FROM DS_JOBS WHERE NAME = 'Test'
>QUIT
It is OK

Can any one of you post kindly advice here... :)

Posted: Wed Sep 09, 2009 6:30 am
by ArndW
try

Code: Select all

dssh<<eof
pterm case noinvert
SELECT JOBNO FROM DS_JOBS WHERE NAME = 'Test';
QUIT;
eof
Note the switching off of case inversion and the semicolon on the SQL

Posted: Wed Sep 09, 2009 8:31 pm
by ray.wurlod
... but lose the semi-colon after QUIT

Posted: Fri Sep 11, 2009 2:45 am
by hailun
dssh<<eof
pterm case noinvert
SELECT JOBNO FROM DS_JOBS WHERE NAME = 'Test';
QUIT
eof

Hi ArndW&ray,
Thank you for your kindly inputs,and the script as above works,I have another question here,is there any way so as I have transfer the output of the Select query to one Unix variable or plain file. I have tried adding redirection symbol '>'
following <<eof and eof and SELECT JOBNO FROM DS_JOBS WHERE NAME = 'Test'; but none of them works,,,

:)

Posted: Fri Sep 11, 2009 3:24 am
by ArndW
How about just using SH scripting
(from UNIX)
cd {project directory}
dssh "SELECT JOBNO FROM DS_JOBS WHERE NAME = 'Test';" > textfile.txt

Posted: Fri Sep 11, 2009 6:09 am
by hailun
Hi ArndW,
Thank you for input, the method mentioned does work,bu it is said it is not a good habit to run dssh/uvsh under other paths than $DSHOME,
And I have achieved this by function calling,detailed as following:
。。。。。。。。。。。。。。。。
run_dssh()
{ a=$1
b=$2
cd $a
dssh<<eof
LOGTO $2
SELECT * FROM DS_JOBS;
QUIT
eof
}

run_dssh $DSHOME $pro_name > ./filename
。。。。。。。。。。。。。。。。
Hence the record returned by the SELECT query will be returned to file filename under present path

However,I have another question now,is there any way to run "dssh SELECT * FROM RT_LOG$HASH_NUM" under path $DSHOME,however the RT_LOG$HASH_NUM" is under some project path
ArndW wrote:How about just using SH scripting
(from UNIX)
cd {project directory}
dssh "SELECT JOBNO FROM DS_JOBS WHERE NAME = 'Test';" > textfile.txt ...

Posted: Fri Sep 11, 2009 6:17 am
by ArndW
I don't know why you think it is bad to call up dssh outside of the $DSHOME directory - I think it is better and safer, as the "UV" account, if inadvertantly modified, can affect all projects on the system.

The question regardnig accessing the RT_LOGnnn file(s) in a different project from within the UV project is answered with a definitive "NO", as you do not want to add remote file pointers to the main UV account.

Posted: Fri Sep 11, 2009 8:50 pm
by hailun
Yeah,although I could not read the fulltext of comments posted by you,I can know you are supporting running dssh under project path other thant $DSHOME :)

And in fact,few persons I know care under which folder the dssh is executed.

I believe we can resolve my last question someday in future...

As you have support resolving two queries factly,I would like to mark this topic resolved here..

Thank you both....

ArndW wrote:I don't know why you think it is bad to call up dssh outside of the $DSHOME directory - I think it is better and safer, as the "UV" account, if inadvertantly modified, can affect all projects on the s ...

Posted: Sat Sep 12, 2009 7:53 pm
by ray.wurlod
dssh can be run satisfactorily in any project directory, as well as in $DSHOME - each project directory is an "account" for dssh. But it is vital that the dsenv script has been executed first - that's why (I believe) advice is usually given to execute in $DSHOME, the location of the dsenv script.