how to pass UNIX script(Procedure) output to job parameter?

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
vbeeram
Participant
Posts: 63
Joined: Fri Apr 09, 2004 9:40 pm
Contact:

how to pass UNIX script(Procedure) output to job parameter?

Post by vbeeram »

Hi,

I have a db2 procedure in my UNIX script,when i execute it returns a value,i need to pass that value into (Job Parameter) to use in Transformer.

I tried with execSH and i passed path and file name as Input Value.
Then how to pass that output to job parameter?


Thanks
Beeram
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

you will need to append that value to your param file in the format DS Jobs accepts it.
-param param name=param value
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

From a before-job routine? Can't set a jobs parameter values from its before-job routine. Consider using a staging variable in your transformer, and for the initialization of the value do the ExecSH call to your script to get the startup value. :wink:
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
vbeeram
Participant
Posts: 63
Joined: Fri Apr 09, 2004 9:40 pm
Contact:

Post by vbeeram »

Thanks Bland,

as per your guidelines i can call in stage variable but also i need to use that value in another stage(Not in transformer) as job parameter.



Thanks
Beeram
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You mean like a filename or a query value? Instead, use job control to feed the parameter.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
vbeeram
Participant
Posts: 63
Joined: Fri Apr 09, 2004 9:40 pm
Contact:

Post by vbeeram »

I need to use query output.
I wrote job control but not able to pass to job parameter.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Using a Sequencer a Routine stage can call your script, or in Batch a CALL DSExecute(...) will return the screen output and return code of the script. Choose your weapon.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
vbeeram
Participant
Posts: 63
Joined: Fri Apr 09, 2004 9:40 pm
Contact:

Post by vbeeram »

Thanks bland, i am almost done
but still i have doubt on passing value :

Below is my code :


hjob1=DSAttachJob("demojob2",DSJ.ERRFATAL)
IF NOT(hjob1) then
CALL DSlogFatal("Job Failed:demojob2","JOB ABORTED")
END

Unixcmd="/fdev/users/10001/Proc.shl"
CALL DSExecute("UNIX",Unixcmd,Scroutput,RetCode)



how to pass Scroutput(output) value to parameter ?



Thanks
Beeram
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

ErrCode = DSSetParam(hJob, ParamName, ScrOutput)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

ray.wurlod wrote:ErrCode = DSSetParam(hJob, ParamName, ScrOutput)

Code: Select all

ErrCode = DSSetParam([i]hJob[/i], [i]ParamName[/i], ScrOutput<1>)
Is usually what I have to do. You could also use field().
Mamu Kim
vbeeram
Participant
Posts: 63
Joined: Fri Apr 09, 2004 9:40 pm
Contact:

Post by vbeeram »

Thanks Bland,

I wrote this code in job control within the same job.
and i declared a parameter ScrOutput in job parameters with some default value then i called ScrOutput parameter into Transformer.
This not working properly .when i ran it is taking time ,never end the job
unless i kill that one.

hjob=DSAttachJob("demojob",DSJ.ERRWARN)
status=DSRunJob(hjob,DSJ.RUNNORMAL)
Unixcmd="/fdev/users/11001/Proc.shl"
CALL DSExecute("UNIX",Unixcmd,ScrOutput,RetCode)
ErrCode=DSSetParam(hjob,"ScrOutput",ScrOutput)

Thanks
Beeram
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Post by ogmios »

vbeeram wrote: hjob=DSAttachJob("demojob",DSJ.ERRWARN)
status=DSRunJob(hjob,DSJ.RUNNORMAL)
Unixcmd="/fdev/users/11001/Proc.shl"
CALL DSExecute("UNIX",Unixcmd,ScrOutput,RetCode)
ErrCode=DSSetParam(hjob,"ScrOutput",ScrOutput)
You first run demojob and then you still want to put a parameter on it. Your order is wrong:
- first execute your UNIX script (and remember about the limited environment you get)
- DSAttachJob
- DSSetParam
- DSRunJob

Ogmios
In theory there's no difference between theory and practice. In practice there is.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Attach, check status, reset if necessary and detach and attach again, set all parameters, set run limits, run job, wait for finish, check status.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Post Reply