Page 1 of 1

Before job subroutine

Posted: Thu Jun 05, 2008 1:11 am
by das_nirmalya
if i use a unix shell script as a before job subroune in job property. how can i use output of this unix script in a transformer used in that job.

i.e i want to use the output value for some comparision etc

Posted: Thu Jun 05, 2008 1:18 am
by ray.wurlod
Without writing a routine there is no way you can achieve what you ask in a server job. This is because the Transformer stage executes in a separate process to the job process (which executes the before-job subroutine). You need to "park" the value somewhere - maybe a file, maybe the job's user status area - and recover it within the routine executed by the Transformer stage.

Posted: Thu Jun 05, 2008 6:18 am
by chulett
You can't. Do it in a separate session, store that value in some manner such that you can retrieve it later and pass it in as a job parameter.

Posted: Thu Jun 05, 2008 8:07 am
by PhilHibbs
Is there not a DS routine that you can call that sets Job Parameters?

Update: A quick search reveals the DSSetParam function, but can this be called while a job is running?

Update2: I've tried and this appears to not work. Params probably get initialised before the Before Job Routine is called. Boo!

Posted: Thu Jun 05, 2008 8:56 am
by chulett
Exactly, you 'set params' before starting the job, after it starts it is too late.

Now, don't tell anyone but I have seen people that have 'hacked' things (or otherwise have an intimate knowledge of the internal structures) and thus know how to sneak under the wire and actually update the current value of a parameter before job. Neither a Best Practice nor a supported methodology that be.

Posted: Thu Jun 05, 2008 9:00 am
by PhilHibbs
It seems tremendously inconvenient that there is no way for a Job to perform a single computation at the start that is later used either in multiple places (Transformers) or for multiple rows. As I understand it, you can't call a Routine in the initialisation of a Stage Variable either.

Correction: You can call a Routine in the initialisation! This will probably do for my situation.

Posted: Thu Jun 05, 2008 9:22 am
by chulett
Bingo! :D

Posted: Thu Jun 05, 2008 10:54 am
by PhilHibbs
So, getting back to the OP's requirement, you could call a DS Routine in the initialisation of a Stage Variable, and in that DS Routine, read the output of the shell script that has been redirected to a file.

Posted: Thu Jun 05, 2008 11:32 am
by chulett
Sure, more than likely. I mean, you can do it but you would only be able to use the value in Transformers. If you needed it in a source query in an passive stage, for example, that would need to be an actual job parameter.

Posted: Thu Jun 05, 2008 2:13 pm
by ray.wurlod
You could also use a before-stage subroutine in the Transformer stage to do the same thing and, since it's in the same process, transfer values through system variables such as @USER0 through @USER4 back into the Transformer stage. But the OP's stated requirement (and thread subject) was "before job subroutine".