COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Cognos Administration => Topic started by: anjan on 22 Nov 2012 07:49:57 AM

Title: Triggering Cognos job from Script
Post by: anjan on 22 Nov 2012 07:49:57 AM
Hi All,

I am using script which provided by cognos(trigger.sh) to run cognos job, based on the success of this script I want to run another scripts which does another active, But I am not able to track the success or failure on trigger.sh as trigger.sh as script is not giving any error code or exit code if job fails.

Is there any way to trap this.

Thanks
Title: Re: Triggering Cognos job from Script
Post by: Danno on 22 Nov 2012 08:52:23 AM
I am assuming that you are running this on Linux but it should apply to most *nix.

I usually put a variable after the command I execute that hold the value of $?.

Something like RC=$?

Then use an if statement to evaluate the output of $RC. You can also end your script with "exit $?" and get output from the script.

Hopefully this points you in a good direction.

Title: Re: Triggering Cognos job from Script
Post by: anjan on 22 Nov 2012 09:26:16 AM
Hi Danno

I have used this but the variable gives only the sucess of the script, whether it trigred or not, but it does not give the status of cognos job.

The other thing  I noticed is the script give exit code immediately and does not wait for cognos job to finish.


Thanks
Title: Re: Triggering Cognos job from Script
Post by: Danno on 22 Nov 2012 01:08:04 PM
Where are you placing the variable? That would be my question. Unfortunately we don't run shell scripts for Cognos here but I do use them a lot for other things and putting the variable right after the Cognos job in the script should get you a return value.

Here is a simple example of how I would do this:

echo hello
echo $?    # Exit status 0 returned because command executed successfully.

boguscmd
echo $?    # Exit status non-zero returned because command executed unsuccessfully.



Title: Re: Triggering Cognos job from Script
Post by: anjan on 27 Nov 2012 06:30:43 AM
I have used the same in my script but still its not giving me the exit code for job but its give exit code trigger script, if the job fails its still gives ge suess code
Title: Re: Triggering Cognos job from Script
Post by: Danno on 27 Nov 2012 10:15:52 AM
I am not sure where to take you from here. I don't have a similar setup to test this on. Perhaps someone else can jump in or you can post your script for us to review.
Title: Re: Triggering Cognos job from Script
Post by: vasudev_chavan on 19 Feb 2013 06:24:37 AM
We can complete this task and logic will be as follows.

1. Trigger report.
2. Monitor the exist level code with step 3.
3. Also add a task of writting the report status to a DB/table using a event studio job.
4. Depending on the flag written to the DB carry on the future jobs/activity.
5. Reset the value in DB once the future task is completed.