passing Unix command Output as command in Batch job

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
sumeet
Premium Member
Premium Member
Posts: 54
Joined: Tue Aug 30, 2005 11:44 pm

passing Unix command Output as command in Batch job

Post by sumeet »

Hi ,

I am trying to pass parameter which I get from a file to the batch job.

The output of unix command is correct I check it using DSLogInfo before the DSSetParam step. But the value is not passed to the Parameter. I dont understand why. Here's the code


Code: Select all

Cmd = "cat /clocal/ivp/dvlp/tmp/Param.txt":"|cut -c2-5"
	 
        Call DSExecute("UNIX", Cmd, Output, SystemReturnCode)

        Ans = Output
      
        
* Setup Test7Job, run it, wait for it to finish, and test for success
         hJob1 = DSAttachJob("Test7Job", DSJ.ERRFATAL)
         If NOT(hJob1) Then
            Call DSLogFatal("Job Attach Failed: Test7Job", "JobControl")
            Abort
         End
         ErrCode = DSSetParam(hJob1, "$ivpDirParm", "$ENV")
         ErrCode = DSSetParam(hJob1, "$ivpDB2User", "$ENV")
         ErrCode = DSSetParam(hJob1, "$ivpDB2Passwd", "$ENV")
         ErrCode = DSSetParam(hJob1, "$ivpDB2DBStg", "$ENV")
         ErrCode = DSSetParam(hJob1, "$ivpDirTmp", "$ENV")
         Call DSLogInfo('Output = ': Output, 'Msg') /*Output=PH02*/
         ErrCode = DSSetParam(hJob1, "PHID",Output) /*here PHID=''*/
         ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
         ErrCode = DSWaitForJob(hJob1)
         Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
         If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
            * Fatal Error - No Return
            Call DSLogFatal("Job Failed: Test7Job", "JobControl")
         End
Can any of DS gurus help me.

Thanks
Sumeet
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Are you getting an error? Or it just "doesn't work"? :?

Try passing Output<1> to the parameter value rather than just Output.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sumeet
Premium Member
Premium Member
Posts: 54
Joined: Tue Aug 30, 2005 11:44 pm

Post by sumeet »

Thanks Chulett

This worked....so is it a syntax where when u pass parameter from command.

Output<i>..i is the count of prameters passed...in this case 1.

Thanks
Sumeet
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No, not parameters passed.

You have to keep in mind the fact that your 'Output' from DSExecute is not a simple string, it's a dynamic array of values. That syntax just means take the first entry from it, which is all you really wanted in this case. If your output was multiple 'records', each would be accessed in a similar manner.

When you take everything in one string, you get the bits that make up the internal structure of the array along with the data - stuff like the @FM Field Marks... or whatever the secret stuff that is in there. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply