running shell script from after job subroutine
Moderators: chulett, rschirm, roy
running shell script from after job subroutine
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
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
-
- Premium Member
- Posts: 457
- Joined: Tue Sep 25, 2007 4:05 pm
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!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.
Vivek Gadwal
Experience is what you get when you didn't get what you wanted
Experience is what you get when you didn't get what you wanted
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
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 457
- Joined: Tue Sep 25, 2007 4:05 pm
It is always a good practice to use the relative or absolute path names. So, using the following syntax might work:ayan wrote:I actually looked for the trigger file in $DSHOME path.Should I look into someplace else?
Code: Select all
touch ./<file name>
Code: Select all
touch $DSHOME/<file name>
Vivek Gadwal
Experience is what you get when you didn't get what you wanted
Experience is what you get when you didn't get what you wanted
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.
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.
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#)
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.
Code: Select all
cmd='touch ':TriggerPath:'/mytest.trg'
Call DSExecute('UNIX',Cmd,Output,ReturnCode)
Call DSLogInfo ( "Audit Routine Returns ":ReturnCode,"Routine")
YourRoutine(#p_TriggerPath#)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 457
- Joined: Tue Sep 25, 2007 4:05 pm
Exactly...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.
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
Experience is what you get when you didn't get what you wanted
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
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