Page 1 of 1

Execute command activity output is not working

Posted: Mon Feb 09, 2015 3:45 am
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

Posted: Mon Feb 09, 2015 8:12 am
by chulett
So... which part of what you posted is the 'not working' part?

ps. Redirect stderr to /dev/null

Posted: Mon Feb 09, 2015 10:55 am
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 !!!!

Posted: Mon Feb 09, 2015 12:58 pm
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.