Getting ExecuteCommand CommandOutput value in a sequencer

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Getting ExecuteCommand CommandOutput value in a sequencer

Post by abc123 »

I have a sequencer loop where I have an ExecCommand followed by a JobActivity stage. In the ExecCommand, I am calling an UNIX command, cat filename, which has a value. I would like to do ExecCommand.CommandOutput to get this value, add 1 to it and use that value as one of the paramters of the job in the following JobAcitivity's job. This doesn't work. Any ideas would be appreciated.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Why it doesn't work? Are you getting any error or it doesnt give the expected value? Explain how are you passing the value.
You can use the ReturnValue of the ExecuteCommand Acitivity to pass the value of the output. And you can manipulate the same in the Job.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

It doesn't give the expected value. In the parameters of the JobActivity stage, I am doing ExecCommand.CommandOutput + 1.
This value should be the parameter value in the job of the JobActivity stage. I always get a 1. I tried ReturnValue as well. If I change the 1 to a 3, I get a 3.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You are missing a dollar sign.

Code: Select all

ExecCommand.$CommandOutput 
In version 7.1 and later you can select this from the "Add Job Parameter" dialog.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

ray thank you for your response.

Actually I have the $ and I am picking from the Acitivity Variable pop-up. I am not typing it in.
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

What's interesting is, in the log it says "Output from command ====>
2" for the ExecCommand activity which means it is returning the right value. It is just during the addition or in the Job Activity stage that the value is getting lost.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Try just passing CommandOutput to the Job Activity and add the value 1 inside job.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I would try:

Code: Select all

ExecCommand.$CommandOutput<1> + 1
-craig

"You can never have too many knives" -- Logan Nine Fingers
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

I tried ExecutCommand.$CommandOutput without the addition. This completely errors the job out.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What 7.x version of DataStage are you running? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

craig that did it. ExecCommand.$CommandOutput<1> + 1 worked. I am using version 7.5.1A. Can anyone explain why it worked? What does the <> work? It seems like an array element.

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

Post by ray.wurlod »

The command output includes line terminators. These are translated by DataStage into field marks (@FM) so that what you get is a dynamic array containing one field per line of output. The angle brackets notation with embedded "1" returns field #1. You could also have specified

Code: Select all

Field(ExecCommand.$CommandOutput, @FM, 1, 1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

Thanks ray. Can you tell me where I can read up more about @FM? I looked in to PX Jobs Developers Guide and Advanced Guide but couldn't find any details.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Look into the Basic.pdf. Its a Field Marker, system variable.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You would also find it in the Server Job Developer's Guide because a job sequence is just a special case of a server job (and that's the main reason that server jobs aren't going away any time soon).
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