row count check in a file, then run job
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 22
- Joined: Wed Jul 23, 2008 5:59 pm
- Contact:
row count check in a file, then run job
Hi,
I need to check the row count for a file. If it is having more than 1 row, then i run job 1, else i run job 2. How do i do this in a job or sequencer. Thank you
I need to check the row count for a file. If it is having more than 1 row, then i run job 1, else i run job 2. How do i do this in a job or sequencer. Thank you
An Execute Command stage could count the number of records in the file:
After that you just need triggers from there to two Job Activity stages, one could check for $CommandOutput=1 and the other could be simply an Otherwise trigger for when it is greater than one. Assuming the result could never be zero or a 'file not found' error, of course.
Code: Select all
wc -l <filename>
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 22
- Joined: Wed Jul 23, 2008 5:59 pm
- Contact:
Thanks ya. The command works, but the trigger part, still confusing to me.
what i need to do is to check whether is there any rows return in the file, if there is no rows return (row count=0) then i need to run another job.
The trigger 'expression type', which one i should use? If i use 'custom and add $CommandOutput=1, it give me the warning 'variable $commandOutput not define. What 'ReturnValue' expression means
what i need to do is to check whether is there any rows return in the file, if there is no rows return (row count=0) then i need to run another job.
The trigger 'expression type', which one i should use? If i use 'custom and add $CommandOutput=1, it give me the warning 'variable $commandOutput not define. What 'ReturnValue' expression means
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Premium Member
- Posts: 22
- Joined: Wed Jul 23, 2008 5:59 pm
- Contact:
-
- Premium Member
- Posts: 22
- Joined: Wed Jul 23, 2008 5:59 pm
- Contact:
This does not work, i tried LEFT as well, it still return filename. I got a solution to return the number only which is
wc -l filename | awk '{print $1}'
But my trigger to run the job still does not work when i put $commandoutput=0 to run the job (my job does not run). The log shows the ouput like this
Output from command ====>
0
wc -l filename | awk '{print $1}'
But my trigger to run the job still does not work when i put $commandoutput=0 to run the job (my job does not run). The log shows the ouput like this
Output from command ====>
0
like ur code
maybe u want post the Filename to $filename but it can't work.
if ur define the file name to filename , it will work.
if u still want to post the filename,u can use the shell script.
Trigger Expression code like this:
Code: Select all
wc -l $filename | awk '{print $1}'
if ur define the file name to filename , it will work.
if u still want to post the filename,u can use the shell script.
Trigger Expression code like this:
Code: Select all
CountRows.$CommandOutput <> 0
You need to handle the Field Mark that is part of the returned value. It's been posted here ad naseum but one more time...
-or-
The code Andy posted should have worked just fine, I'd suggest double-checking it or posting the exact syntax you used so we can.
Code: Select all
Convert(@FM,"",EC_StageName.$CommandOutput)=0
Code: Select all
EC_StageName.$CommandOutput<1>=0
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 22
- Joined: Wed Jul 23, 2008 5:59 pm
- Contact:
there is another way to do this :
code for the command.
code for the parameter,this is the job parameter.
code for the trigger:
it runs well , and u can post the file from job parameter.
code for the command.
Code: Select all
wc -l
Code: Select all
#filename#
Code: Select all
FIELDS(CountRows.$CommandOutput," ",1) > 0