Page 1 of 1

execute command to check for a existance of a file on unix

Posted: Wed Feb 17, 2010 9:08 am
by Chandrathdsx
I am checking for a existance of a file (on unix) using Execute command stage (script: ls #Filename#) and in triggers: 1. if expression type 'OK' branching to file exists link, 2. if expression type 'otherwise' branching to file does not exists and I have other processes from these branches.
It is running fine but giving following warning:
JobControl (@Execute_Command_0): Command ls did not finish OK, reply = '2'

I tried to use CONVERT(@FM, "",Execute_Command_0.$returnvalue) > 1 for file does not exist link but no luck.

Could you please let me know how to get rid of this warning (other than suppressing it) or is there a better way to check for existance of a file?

Thank you!

Posted: Wed Feb 17, 2010 9:13 am
by DSguru2B
Wait for file activity maybe....

Posted: Wed Feb 17, 2010 9:18 am
by chulett
I would use one of the the test operators, perhaps "test -e" or with -f or -s depending on how tightly you need to test it.

Posted: Wed Feb 17, 2010 9:36 am
by Chandrathdsx
chulett wrote:I would use one of the the test operators, perhaps "test -e" or with -f or -s depending on how tightly you need to test it. ...
Craig,
Thank you for the details. I tried with test -e but, still getting the warning when file does not exist:
JobControl (@Execute_Command_0): Command test -e did not finish OK, reply = '1'
But, the branching logic is working same as 'ls #filename#' when file doesn't exist.
[only difference I noticed is for test -e getting return value of 0 if file exists and return value of 1 if file does not exist. and it is not giving any command output(which I do not need). In case of 'ls #filename#' I am getting return value =0 or 2 and with command output as 'fileexsts' 'file not found'.

DSguru2B,
I am reluctant to use 'wait for file' as actually I do not want to wait, I check for existance of a file in a loop and branch based on condition.

Thank you all!

Posted: Wed Feb 17, 2010 10:15 am
by chulett
That's because you are using the 'Automatically handle activities that fail option' but your triggers should override that if you are using the right pair of triggers out of the stage: 'Conditional (OK)' and 'Otherwise'. Are you saying that you are and it still logs the warning? :?

ps. A Wait For File stage with a wait time of zero seconds will do a simple file existence check.

Posted: Wed Feb 17, 2010 10:32 am
by Chandrathdsx
chulett wrote:That's because you are using the 'Automatically handle activities that fail option' but your triggers should override that if you are using the right pair of triggers out of the stage: 'Conditional (OK)' and 'Otherwise'. Are you saying that you are and it still logs the warning? :?

ps. A Wait For File stage with a wait time of zero seconds will do a simple file existence check.
Craig,
Yes, I am using ''Automatically handle activities that fail option' as I want to fail the job for any failure [this sequence has lot of other steps/stages/jobs]. But I am using the right pair, 'Conditional (OK)' and 'Otherwise'. when file not found the othewise issuing a warning.

I tried with 'Wait of File Activity' with zero seconds, using right pair for trigger branches. but still it gives a warning for otherwise (when file doesn't exist): Routine DSWaitForFile did not finish OK, return code = '-14'
Any suggestions? Should I live with warning when file does not exist, if no other options?
Thank you for all the help!

Posted: Wed Feb 17, 2010 10:38 am
by DSguru2B
See if this helps.

Posted: Wed Feb 17, 2010 10:49 am
by chulett
Chandrathdsx wrote:Yes, I am using ''Automatically handle activities that fail option' as I want to fail the job for any failure [this sequence has lot of other steps/stages/jobs].
That's fine and exactly what it is meant to do. I should have been more specific and thought about this for a moment longer - your triggers are working fine otherwise your message would be about an unhandled error being encountered. That specific trigger pair lets the code generater know that you are handling any "error" and that it doesn't have to include code to do that. If you are feeling adventurous, you can change the design and see the difference in the code it generates in the Job Control tab. :wink:

Uncheck the companion compilation option to Log warnings after activities that finish with status other than OK, you don't really need that to achieve your primary goal and it is what is actually causing your issue.

Posted: Wed Feb 17, 2010 4:44 pm
by Chandrathdsx
Thank you.
I unchecked 'Log warnings after activities that finish with status other than OK' to get rid of warning.

Thanks again