Execute command activity output is not working

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
akarsh
Participant
Posts: 51
Joined: Fri May 09, 2008 4:03 am
Location: Pune

Execute command activity output is not working

Post by akarsh »

Hi,

I have seen many post but still not working for me.

I just need to see if file is not present in directory need not to run job and send mail. I am checking as below
In seq in execute command actvity

ls -lrt /Path/*ABC*.xml | wc -l

in trigger section am checking like this
for no file
Trim(ExecFileCheck.$CommandOutput,@FM) = 0
For file
Trim(ExecFileCheck.$CommandOutput,@FM) >=1 (multiple file may come)

But its not working. Output of command from director is

when no file
seq_..JobControl (@ExecFileCheck): Executed: ls -lrt /path/*ABC*.xml | wc -l
Reply=0
Output from command ====>
ls: /path/*RATEE*.xml: No such file or directory
0
When file is present is
seq_..JobControl (@ExecFileCheck): Executed: ls -lrt /path/*ABC*.xml | wc -l
Reply=0
Output from command ====>
1
Please suggest what i am missing.

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

Post by chulett »

So... which part of what you posted is the 'not working' part?

ps. Redirect stderr to /dev/null
-craig

"You can never have too many knives" -- Logan Nine Fingers
akarsh
Participant
Posts: 51
Joined: Fri May 09, 2008 4:03 am
Location: Pune

Post by akarsh »

Hi Chulett,

your reply worked :D

I gave like this in execute command

ls -lrt /path/*RATEE*.xml | wc -l > /dev/null

Trigger condition

File Missing

Trim(ExecFileCheck.$CommandOutput,@FM) <> ''

File Present
Trim(ExecFileCheck.$CommandOutput,@FM) = ''

Above Trigger condition gave correct output, Not sure why earlier one was not working :)

Marking it resolve.

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

Post by chulett »

Well... not exactly what I meant. Your earlier trigger conditions should have been fine if you just added the redirect of stderr to the first command, the one throwing errors when no file exists. One variation:

Code: Select all

ls -lrt /Path/*ABC*.xml 2> /dev/null | wc -l
That would suppress the 'No such file or directory' message and thus allow the zero count to be detected properly by the trigger. Never mind that the original triggers are better documenters of the process.

ps. Forgot to mention you actually redirected stdout to /dev/null which throws away the count... which also means piping to count no longer makes much sense. All your new triggers are checking for is error text from the "ls" command - none comes back, it must have found files.
-craig

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