Script to abort the job

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
Poornagirija
Participant
Posts: 65
Joined: Fri Nov 19, 2004 12:00 am

Script to abort the job

Post by Poornagirija »

HI folks, :D
We are working on Ds 7.5.1.

we have one job.Let me explain that.
The source is xl sheet.so we are using unix script (that includes java script) which will convert xl to csv format.
we are calling the script in before subroutine.
This is followed by one job which will populate the data to a table.

We have one minor issue.sometimes while converting xl to csv we have 0 bytes in the source file.so no data is populated to the table. :shock:
We are interested to do the following...
If there is no data in the file then the job has to be stopped at the stage itself or it should get aborted so that we can send an email notification.

The unix script will send a mail if there is no data but it wont stop our job.

Is there anyway that our script can abort the job itself.
Or can we do that in routines?

Any suggestions will be helpful to us.

Many thanks in advance.
With Regards,
Poornagirija.

"Don't limit your challenges - challenge your limits"
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The before-job routine will automatically fail the job if the return code from the shell is non-zero. So make your shell script return an error.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Create a shell script to check the size of the file and based on the return code direct the sequence to act accordingly.

Code: Select all

[[ -s $IFM_INPUT_001 ]]

RC=$?

if [ $RC -ne 0 ] ; then
 return 0
fi
if [ RC -eq 0 ] ; then
  return 1
fi
Use the above to check the size. If the filesize is 0Kb then the above will return 1 (error). 'On Error' from the Execute command trigger the email notificaiton.
Better not to abort.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Poornagirija
Participant
Posts: 65
Joined: Fri Nov 19, 2004 12:00 am

Post by Poornagirija »

HI ArndW,

Thanks for your suggestion.

we will do that..
With Regards,
Poornagirija.

"Don't limit your challenges - challenge your limits"
Poornagirija
Participant
Posts: 65
Joined: Fri Nov 19, 2004 12:00 am

Post by Poornagirija »

Hi kumar,
Thanks for your script :D
With Regards,
Poornagirija.

"Don't limit your challenges - challenge your limits"
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
Another option might be:
get the link row count of the relevant link in a UserVariable stage after the reading job finishes (using DSGelJobLinkInfo()) then in a nested condition stage upon zero rows trigger notify via mail (or what ever) and finish and otherwise trigger to do the process you need.

In any case zero rows will most likely make no effect on anything.

And most important you will not abort the job :!:

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Post Reply