Retrieve information from a Pre job routine

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
nilotpalr
Participant
Posts: 29
Joined: Tue Dec 10, 2002 2:54 am

Retrieve information from a Pre job routine

Post by nilotpalr »

Hi All,
I need to retrieve the timestamp associated with a file on my Unix system. I am aware of the Unix command that will give me the timestamp. This command i can use with ExecSh Prejob routine. But How do I store the result of this command in a variable. Urgent help is needed.
Thanks in advance..
Nilotpalr
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Probably should do it in a controlling batch job that then runs your job. The batch could take in the filename as a parameter, execute the Unix command on the file, retreive the result and pass it to your job as another parameter.

-craig
nilotpalr
Participant
Posts: 29
Joined: Tue Dec 10, 2002 2:54 am

Post by nilotpalr »

Probably should do it in a controlling batch job that then runs your job. The batch could take in the filename as a parameter, execute the Unix command on the file, retreive the result and pass it to your job as another parameter.

-craig
Ya that is the logic.. but how do i retrieve the information.. The prejob routine is returning only the status.. If it was success or failure and not the result. Ineed to store the result in a variable/parameter.. Pls suggest how..
thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

One of the arguments of 'DSExecute' returns the output from your command. Here is a psuedo code snippet from one of my routines that executes a Unix command and then pulls the results (assuming a single returned row) into a variable:

FileCmd = "whatever you need executed"
Call DSExecute("UNIX",FileCmd,CmdOutput,CmdReturnCode)
If CmdReturnCode <> 0 Then
Call DSLogInfo(FileCmd, "ERROR")
Call DSLogWarn(CmdOutput, "ERROR")
[Do something appropriate here]
End
DesiredResult=CmdOutput<1>

There may be a better way, but this works for me. You could then use DSSetParam to pass the result on to a job.

HTH,

-craig
Post Reply