Problem using unix command from execute command stage

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

Moderators: chulett, rschirm, roy

Post Reply
swapna07
Participant
Posts: 22
Joined: Fri Mar 08, 2013 11:29 am
Contact:

Problem using unix command from execute command stage

Post by swapna07 »

Hi All,

Scenario : I have to search a reject file in one of the unix path/directory after one job has run. If the reject file is present then the job sends a email notification to users with the reject file. If no reject file, then it sends a success email.

Solution: I have used Execute Command stage after my job runs in sequencer to achieve this. This stage has "find" in command line with proper path in paramters : /etldata/q2c01/error/ -name "Q2C_Rej_*" -ls | wc -l

Where Q2C_Rej_timestamp is my file name.

Also in Trigger tab i have mentioned the condition as:
Name Expression type Expression
Lnk_Rej_Notify ReturnValue-(Conditional) 0
Lnk_Rej_Notify ReturnValue-(Conditional) 1

But when I am trying to run the seq, it is aborting with error as below :
Command wc -l did not finish OK, reply = '1'
Unhandled failure (1) encountered executing command wc -l

Can anyone please help.

Thanks in advance.
PaulVL
Premium Member
Premium Member
Posts: 1315
Joined: Fri Dec 17, 2010 4:36 pm

Post by PaulVL »

Did some knucklehead insert a file in your $PATH called "wc" ?

Does your command work when you try it from a command line when you are sitting in your project directory?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do an exact search here for "Unhandled failure"... you have the Automatically Handle option on and your command did not return zero. That = failure.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Look in the log for the event that contains the output from your Execute Command activity. Report back the error message that you see there.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Problem using unix command from execute command stage

Post by chulett »

swapna07 wrote:But when I am trying to run the seq, it is aborting with error as below :
Command wc -l did not finish OK, reply = '1'
Unhandled failure (1) encountered executing command wc -l
Hence my reply. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

I believe the problem is: -name "Q2C_Rej_*"

You need to use single quotes to get the wildcard to activate. With the double quotes it is looking for a filename that is actually called Q2C_Rej_*
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

An additional problem. Even once working, the base problem will still be the fact that a count of 1 will be considered an 'unhandled failure' with that option turned on unless the sequence job thinks you are handling the failure. And how you do that is documented in the same place that option is.
-craig

"You can never have too many knives" -- Logan Nine Fingers
swapna07
Participant
Posts: 22
Joined: Fri Mar 08, 2013 11:29 am
Contact:

Post by swapna07 »

Thanks for reply.The problem was with find command. Although it does return values 0 &1, but somehow it is not working.When i tried with other option it worked.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What "other option", exactly?
-craig

"You can never have too many knives" -- Logan Nine Fingers
swapna07
Participant
Posts: 22
Joined: Fri Mar 08, 2013 11:29 am
Contact:

Post by swapna07 »

I used "wc -l" in command line instead of "find" and searched if the file created is more than zero byte. So depending upon whether the file is zero byte or greater than that we would direct our o/p to desired link. Reject file is created in both the scenario whether we have reject or not. The difference would only be with size of file. However I still dont see good reason on why find command was not working.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Andy noted a good reason. However, there's a big difference between checking to see if a file exists versus checking to see if it is empty or not. Use whichever method is appropriate for your need.

ps. "test -s" would work as well for the latter.
-craig

"You can never have too many knives" -- Logan Nine Fingers
swapna07
Participant
Posts: 22
Joined: Fri Mar 08, 2013 11:29 am
Contact:

Post by swapna07 »

Thanks. I will try.
Post Reply