execSH Problem..plz help

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
chooi
Participant
Posts: 19
Joined: Wed Jan 26, 2005 8:33 pm

execSH Problem..plz help

Post by chooi »

Hi , I want to delete a sequential file after run a job. I had write a shell script to delete the sequential file .So , inside the job properties , I set the After-job-routine to "ExecSH" and put the following value inside the input value :
"/u02/dsclear.sh ":DATAPATH:" ":SYSTEMNME:" ":JOBNAME:"" "/u02/dsstg/data/DEV_PDS_MY/UtilityScript/log/dsclear.log"

DATAPATH,SYSTEMNME,JOBNAME are the parameters to pass inside the shell script ,I had set their values as STAGE VARIABLE inside transformer.

is it necessary to put in the log file? r the statement ok?Plz help.Thanks.


i m newbie to DS, plz help and show me in detail.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can prepare a script as a target file and run that in your post job.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Chooi,

whatever you put into your ExecSH command will be parsed and then passed to your UNIX shell; so what you posted in your note looks correct. What is the problem you are having? Does the delete function?
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

ArndW,

I think the question is the method to use values stored in the link and stage variables to form part of the command.
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Re: execSH Problem..plz help

Post by naren6876 »

Use the following statement in your after job routine.
Call DSExecute("UNIX","rm FILEPATH", Output, SystemReturnCode)
ErrorCode=0[/quote]
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

make it as "rm " : FILEPATH - where FILEPATH is your parameter.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: execSH Problem..plz help

Post by chulett »

chooi wrote:DATAPATH,SYSTEMNME,JOBNAME are the parameters to pass inside the shell script ,I had set their values as STAGE VARIABLE inside transformer.
This is the crux of the problem. Stage Variables are (as their name implies) local to the stage in which they are defined and used. Outside of that stage - or after job - they do not exist.

They would need to be Job Parameters to work in this manner, but that also means they would have to be known when the job starts, not derived during the job. Is that a possibility?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Craig has explained clearly why what you're attempting to do won't work.

I think Sainath.Srinivasan has given you a pretty clever way to achieve what you desire in his first post in this conversation. Perhaps the brevity of his post didn't make this obvious.

In the transformer in which you know the values of your stage variables:
1) Add an extra output file (e.g. MyShellScript.ksh)
2) Create a single large column in this file (e.g. MyShellScript VarChar(1000))
3) Build the shell script content that you want to execute in the output derivation for this column
4) If you know the values at the beginning of the process, set the output constraint to @OUTROWNUM = 1, or if you don't know the values until the end of the process, pass it through an aggregator using "Last"

Now the shell script is in a persistent store on disk that you can execute "after job".

Mike
chooi
Participant
Posts: 19
Joined: Wed Jan 26, 2005 8:33 pm

Post by chooi »

Hi all,
I already know the parameters that i have to passed in before the job run.I think the easiest way to do is just put in the run statement to run the script in "input value" of after-job subroutine in "job properties" window.
Below is my statement :
"cd /u02 ; ./dsclear.sh "/u02/dsstg/data/DEV_PDS_MY" "CMS" "CMSPrepRefSeqFile/dummy""

Any comment?please correct me if i am wrong.Thanks.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Quotes are killing you. You have embedded quotes. Remove them.
Mamu Kim
chooi
Participant
Posts: 19
Joined: Wed Jan 26, 2005 8:33 pm

Post by chooi »

Hi Mike,
u know i am the newbie to DS. Could u plz exlain in detail how your suggestion works. Thanks a lot.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Change it to:

Code: Select all

"cd /u02 ; ./dsclear.sh /u02/dsstg/data/DEV_PDS_MY CMS CMSPrepRefSeqFile/dummy"
Mamu Kim
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Chooi,

Based on your statement:
"I already know the parameters that i have to passed in before the job run."
I don't think you need to dynamically generate a shell script from within your job (which was the technique that I tried to communicate to you). You would only attempt to do that if the values were unknown when the job started, and the job was responsible for deriving their content.

The correction that Kim gave you should fix your problem, but you really shouldn't be hard-coding things like path names. These will likely change when you move from DEV to TEST to PROD. Since you know the values before the job starts, you should use job parameters within the job and in the after job routine (e.g. jpScriptDir, jpDataDir, etc.)

Mike
chooi
Participant
Posts: 19
Joined: Wed Jan 26, 2005 8:33 pm

Post by chooi »

Thanks guy/gal . u all r helpful.
Post Reply