Passing output from shell script to a 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
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Passing output from shell script to a job

Post by pnchowdary »

Hi Guys,

After executing a shell script using Execute Command stage in job sequencer, How do I capture the output value returned by the shell script and pass it on to a server job, without writing it to a sequential file and again reading it? Is there a direct way to do it?.

Thanks,
Naveen
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Use a filter stage. You could also pass in shell variables as parameters. You could also use pipes.
Mamu Kim
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Duke,

I am using server jobs, so I guess I can not use filter stage. I will try the other options.

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

Post by ray.wurlod »

In the Job Activity, click on Insert Parameter Value. This opens the External Parameter Helper dialog, on which you will see the Execute Command Activity.
Expand this and you will see three things that you can use to supply a value to the currently selected job parameter.
  • $CommandName the name of the command (shell script)

    $ReturnValue the exit status of the command

    $CommandOutput anything on the command's stdout
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Ray,

Thanks for the detailed solution to my problem. I will follow your solution.

Thanks,
Naveen
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Ray,

I tried to implement the solution pointed out by you and I am getting an error.
I have defined a job parameter called TestOutput and have populated it with the output value of $CommandOutput (actual value is "Execute_Command_0.$CommandOutput")

The following is the log of the job run
TESTEXESCRIPT..JobControl (@Execute_Command_0): Executed: /FTP/CPS/FTPPLAYGROUND/DEV/test.sh
Reply=0
Output from command ====>
/FTP/CPS/FTPPLAYGROUND/DEV/serial_test.txt

TESTEXESCRIPT..JobControl (@Job_Activity_1): Controller problem: Error calling DSSetParam(TestOuput), code=-4
[ParamValue/Limitvalue is not appropriate]
I am not using any LimitValue, therefore the problem is with the parameter value that I am passing. Could you please tell me what I am doing wrong ?

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

Post by ray.wurlod »

What type is the job parameter? String? Integer? Date? The error code -4 says that the value you've provided is not apporpriate for the parameter type. What value was provided? Check for line terminator characters in $CommandOutput - you may need to trim them.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Ray,

Thanks for the prompt reply to my post. The parameter had some null space embedded in the string. I removed the null space and it worked. Once again thanks for pointing me in the right direction.

Thanks,
Naveen
meorz
Participant
Posts: 8
Joined: Thu Jul 28, 2005 6:00 pm

Post by meorz »

Guys, I couldn't see anything inside the "Insert Parameter Value" could you gives me the exact convention to put in the program name and output parameters?

btw, I am using Windows

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

Post by ray.wurlod »

Do you have an upstream Execute Command activity? Without that you won't see anything.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
meorz
Participant
Posts: 8
Joined: Thu Jul 28, 2005 6:00 pm

Post by meorz »

That was unbelieveably fast!

How do check if I have that?

There is only the Header or something (main node) but I can't click anything.

btw, I have a friend working with me here who claims to know you ;)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Your job sequence must have, as a very minimum:

Code: Select all

ExecuteCommand  ----->  JobActivity
I believe yours does not.
When it does, and the Execute Command activity's properties have properly been filled in, you can do what was described above.
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