Page 1 of 1

Problem using unix command from execute command stage

Posted: Fri Jul 25, 2014 3:39 am
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.

Posted: Fri Jul 25, 2014 7:24 am
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?

Posted: Fri Jul 25, 2014 7:28 am
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.

Posted: Fri Jul 25, 2014 4:26 pm
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.

Re: Problem using unix command from execute command stage

Posted: Fri Jul 25, 2014 8:53 pm
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:

Posted: Sat Jul 26, 2014 9:51 am
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_*

Posted: Sat Jul 26, 2014 10:30 am
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.

Posted: Fri Aug 01, 2014 12:42 am
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.

Posted: Fri Aug 01, 2014 7:13 am
by chulett
What "other option", exactly?

Posted: Thu Aug 07, 2014 2:51 am
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.

Posted: Thu Aug 07, 2014 7:24 am
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.

Posted: Tue Aug 12, 2014 2:53 am
by swapna07
Thanks. I will try.