running shell script from after job subroutine

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
ayan
Participant
Posts: 64
Joined: Fri Oct 23, 2009 4:09 am

running shell script from after job subroutine

Post by ayan »

I am trying to run a shell script from after job subroutine without much success.I have crosschecked that the shell script statement is correct.Following is a code snippet :

cmd='touch mytest.trg'

Call DSExecute('UNIX',Cmd,Output,ReturnCode)
Call DSLogInfo ( "Audit Routine Returns ":ReturnCode,"Routine")

Could you please suggest anything?Let me know if any additional information is needed.

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

Post by chulett »

What is your actual problem? Hint: since you are using a relative path, if you can't find mytest.trg look in the Project directory.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

chulett wrote:What is your actual problem? Hint: since you are using a relative path, if you can't find mytest.trg look in the Project directory.
I think that is exactly the problem. I do not see anything wrong with the DSExecute() syntax. However, I am not in front of DS right now, so I could not verify!
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
ayan
Participant
Posts: 64
Joined: Fri Oct 23, 2009 4:09 am

Post by ayan »

I actually looked for the trigger file in $DSHOME path.Should I look into someplace else?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In the job's project directory. As noted. Typically:

Code: Select all

cd $DSEngine/../Projects/<project name>
-craig

"You can never have too many knives" -- Logan Nine Fingers
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

ayan wrote:I actually looked for the trigger file in $DSHOME path.Should I look into someplace else?
It is always a good practice to use the relative or absolute path names. So, using the following syntax might work:

Code: Select all

touch ./<file name>
or

Code: Select all

touch $DSHOME/<file name>
A Quick question for the OP - don't you have a dedicated directory for the trigger files? If so, I would recommend placing the touch files in that location rather than having it in the $DSHOME directory, unless I am missing something here.
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's a good practice to use full pathnames, your first suggestion won't actually change the issue and is functionally equivalent to what they are already doing. :wink:

I too would assume their 'trigger' files should be someplace specific and I doubt that $DSHOME would (or should) ever be that place. Best Practice would be to use a parameter for that file path so it can be easily changed from environment to environment or if someone just plain old changes their mind. Not that that ever happens. :roll:

Code: Select all

cmd='touch ':TriggerPath:'/mytest.trg' 

Call DSExecute('UNIX',Cmd,Output,ReturnCode) 
Call DSLogInfo ( "Audit Routine Returns ":ReturnCode,"Routine")
This assume that one of the routine arguments (Arg1) has been renamed to TriggerPath so that it is a little more... self-documenting. Then after job you would pass it a Job Parameter which could (but doesn't need to) have the same name:

YourRoutine(#p_TriggerPath#)
-craig

"You can never have too many knives" -- Logan Nine Fingers
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

chulett wrote: I too would assume their 'trigger' files should be someplace specific and I doubt that $DSHOME would (or should) ever be that place.
Exactly...

One of the more dangerous issues arise when some people, without complete understanding on Unix, try to purge those trigger files from the $DSHOME directory. :D
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
ayan
Participant
Posts: 64
Joined: Fri Oct 23, 2009 4:09 am

Post by ayan »

Guys,thanks for your inputs.Actually the problem is not with relative or absolute path name of trigger file.I should have provided more information in the first post itself.Here is what I am trying to do :

This after job sub routine captures the job statistics like start time ,end time,status etc.Next I need to load this info in an audit table.My idea is to call a script from the routine which will take the audit info as arguments and load in the database.So the 'cmd' variable is actually holding the script invocation (with the arguments).But the problem is that the desired script is not getting executed.So I decided to check with a simple touch command and yes,I tried with a fully qualified name for the trigger file too.

I will try to provide some more info related to the execution early next week.

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

Post by chulett »

You should create a job to load your 'job statistics', much easier to do and maintain. You'd have to let us know what 'not getting executed' means - log the Output as well as the ReturnCode to help see what's going on.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ayan
Participant
Posts: 64
Joined: Fri Oct 23, 2009 4:09 am

Post by ayan »

The problem got resolved.Actually I was constructing thescript call dynamically within the routine and setting the variable 'cmd'.The pathname of the script was getting populated incorrectly.Rectified that.Routine is working fine now.Thanks to you all for providing suggessions.

Regards,
Ayan
Post Reply