Hi Folks
I have a requirement where certain extract and transformation need to happen if there is a file that is avaialable . quite simply if a look-up file is available use that to do some lookup and tranform else do another process .
As of now , i have split that into multiple jobs and i use shell script if-else conditions to call seperate sequencers , is there a better way to accomplish this ?
Check for existence of a file
Moderators: chulett, rschirm, roy
Iam kind of getting that , correct me if iam wrong here ,
if i use wait for file activity i can look for appearance of the file and timeout after a certain time .that way will be a way to distinguish if the file exists or not right ? ...
Is that possible to add logic for branching in that case ? or i have to have a nested condition to handle it ..
if i use wait for file activity i can look for appearance of the file and timeout after a certain time .that way will be a way to distinguish if the file exists or not right ? ...
Is that possible to add logic for branching in that case ? or i have to have a nested condition to handle it ..
Sreedhar - just leverage the 'test' capabilities your shell. For example, for korn:
Meaning: Is the $DSHOME 'file' a directory that is writable and executable by the current user?
Do a 'man' on your shell and there should be a section on Conditional Expressions. There should be... several.
Code: Select all
if [[ -d ${DSHOME} && -w ${DSHOME} && -x ${DSHOME} ]] ;then
Do a 'man' on your shell and there should be a section on Conditional Expressions. There should be... several.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Use a wait time of 0 for a single 'file check'.ag_ram wrote:Iam kind of getting that , correct me if iam wrong here ,
if i use wait for file activity i can look for appearance of the file and timeout after a certain time .that way will be a way to distinguish if the file exists or not right ? ...
Is that possible to add logic for branching in that case ? or i have to have a nested condition to handle it ..
Two triggers - Ok and Otherwise. The former trigger defines your 'file found' path while the latter is your 'file not found' path.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Sure SreeSreedhar wrote:Ram,
Can you share, with us the logic, you have been using to find if the file exist or not with in the unix script. Hope that should help us when such a requirement come up.
Thanks in advance.
right now this is what iam doing .
if [ ! -f $lookupfile ]
then
echo "Lookup file [$lookupfile ] not found - Skipping Activity"
ProcP7.sh #sequencer to the process is called here
else
ProcP3.sh #sequencer to the lookup process is called here
fi