Executing dsjob command from routine activity

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

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

Post by chulett »

As you should if literally all you are doing is calling dsjob from the command line. Let us know how it goes. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

Hi,

with the exec command activity the job runs fine.
but there is one issue.

Code: Select all

 execcmd---------jobactivity1-------------jobactivity2
              
now in the first run the execcmd runs fine, but the jobactivity1 fails.
then when we restart the job from director. it shoud start from jobactivity1.

but actually when we restarted the sequence it is starting from execcmd, this is wrong.this is happening because the return from execcmd is 1 and not 0. the sequence is assuming that it failed at execcmd and starts running from execcmd.

is there any way we can handle the returns 1( for sucess) and 2 ( for warnings) after the dsjob command in execcmd.

can i use an if then else statement in the same execcmd after the dsjob command.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Take a look at the error that was generated and then do an exact search here for it. That situation, the error and the resolution have been discussed here many many times.
-craig

"You can never have too many knives" -- Logan Nine Fingers
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

I am not getting any error.
But i do not want the execcmd activity to run again thats all.


What should i search for.
sequence restartablilty?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There would typically be a message about an "unhandled exception" from the Execute Command stage, is that not there? Tell us which compiler options you have enabled in the Sequence job... enable checkpoints, etc.
-craig

"You can never have too many knives" -- Logan Nine Fingers
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

Hi,

Everything checked

add checkpoint
log warning after activities that finish with not OK
aoutomaticaly handle activities that fail
log report messages after each job run

But there is no unhandles exception
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

samyamkrishna wrote:automatically handle activities that fail
This one is the one that takes non-zero output from stages that return a value to mean 'failed' and why it runs again on a checkpoint restart. Try putting a Sequencer set to 'Any' between the Execute Command stage and the next one with two links between them. Set one trigger to 'OK - Conditional' and the other to 'Otherwise' and see if that solves your problem.
-craig

"You can never have too many knives" -- Logan Nine Fingers
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

Hi Craig,

I tried what you said.
unchecked "automatically handle activities that fail "

Then did a fresh run. Execute command worked fine the next activity failed.

Restarted the sequence It did not skip the Execute Command but it ran the dsjob command in the execute command activity.

Or i am missing some thing in what you have said.


Then

Code: Select all

;if [ $? -eq "1" -o $? -eq "2" ]; then return=0; else return=1; fi; exit $return

In the execute command activity i put the above code with the dsjob command. This seems to resolve the issue.

dsjob -run -wait proj job ];if [ $? -eq "1" -o $? -eq "2" ]; then return=0; else return=1; fi; exit $return

Now it runs fine. but is this a right approach?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well... I never said to uncheck anything. I said to modify your sequence in a specific way which it sounds like you did not do.

Also, dsjob with -wait will not return a 1 or a 2, it will return a zero or a non-zero (as in negative) status with the latter being a failure of some kind. You must be using -jobstatus instead as it returns the 'normal' status codes of 1,2,3 etc.
-craig

"You can never have too many knives" -- Logan Nine Fingers
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

Hi,

I have modified the sequence.
a sequencer in between with any and triggers OK conditional and the other trigger otherwise.

Now I ran it with "automatically handle activities that fail " checked.
same issue.

and yes i am using jobstatus.

so changing it to -wait instead of -jobstatus will solve this too right?

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

Post by chulett »

samyamkrishna wrote:so changing it to -wait instead of -jobstatus will solve this too right?
Yes, without the need for any extra checks.
-craig

"You can never have too many knives" -- Logan Nine Fingers
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

Thanks a lot craig. :)
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

I have used ExecSh for executing a shell script and not for directly specifying commands.

For execSh , i ll pass the shell script name and the input arguments.
In order to directly execute commands, i prefer ExecuteCommand stage.

I dont think we can execute the commands directly using ExecSh in routine activity stage,

Please correct me if my understanding is incorrect.

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

Post by chulett »

Your understanding is incorrect. You can use ExecSH to run anything valid to be executed from the shell, hence the name. It really doesn't know or care if that is a script or a string of native operating system functions. Use the O/S functions if that's all you need, cobble together a script if you need more control over them.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply