awk in execute command activity
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 296
- Joined: Sun Nov 16, 2008 7:41 pm
awk in execute command activity
Hi.
In my job, i have a rejection file. If the rejection has any records i have to send a notification.
Lets say i am storing the rejections in a file called "rejs".
So what i have done is
linked the job activity with command activity--> notification
In command activity
command: wc -l
params: rejs
under triggers:
left(command activity. job output, @FM,1)>0
so when the wc -l was executed, output is like
0 rejs
if i use awk '{print $1}' i will get the output as 0.
Where can i add this awk command in execute command activity.
do i need to add one more exec command activity and put
awk '{print $1}' commandactivity.job output.
or can i do this in the already exsiting command activity.
In my job, i have a rejection file. If the rejection has any records i have to send a notification.
Lets say i am storing the rejections in a file called "rejs".
So what i have done is
linked the job activity with command activity--> notification
In command activity
command: wc -l
params: rejs
under triggers:
left(command activity. job output, @FM,1)>0
so when the wc -l was executed, output is like
0 rejs
if i use awk '{print $1}' i will get the output as 0.
Where can i add this awk command in execute command activity.
do i need to add one more exec command activity and put
awk '{print $1}' commandactivity.job output.
or can i do this in the already exsiting command activity.
-
- Premium Member
- Posts: 296
- Joined: Sun Nov 16, 2008 7:41 pm
You should be able to. Thats why my advice above.
Basically
Basically
Code: Select all
wc -l rejs | awk '{print $1}'
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Premium Member
- Posts: 296
- Joined: Sun Nov 16, 2008 7:41 pm
ThanksDSguru2B wrote:You should be able to. Thats why my advice above.
BasicallyCode: Select all
wc -l rejs | awk '{print $1}'
I got it
Previously i never thought i can give the command along with file name
in the command box and leave the parameters box empty.
I was using wc -l in command box and file name in parameters box of exec command activity.
Now i have used "wc -l filename |awk '{print $1}'" in the command box.
Thanks for the responsse
-
- Premium Member
- Posts: 296
- Joined: Sun Nov 16, 2008 7:41 pm
Well,DSguru2B wrote:You should be able to. Thats why my advice above.
BasicallyCode: Select all
wc -l rejs | awk '{print $1}'
I got another issue.
file name actually used contains parameters.
File name wil be like
#path#/rejs.
So when i put this in the command activity, respose is "command activity cannot contain parametes"
If i put the file name in parameters box, i am unable to awk it.
How can i do this?
Split it up so that a part without parameters is in the Command box and the rest (the bit with parameters) is in the Parameter box. All the stage does is stick the two pieces together and then run it.
The only 'trick' to know is when the very first bit (typically a path to a script) is a parameter, then what you do is put "ksh" or "sh" in the command box and everything else in the parameter box.
The only 'trick' to know is when the very first bit (typically a path to a script) is a parameter, then what you do is put "ksh" or "sh" in the command box and everything else in the parameter box.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 296
- Joined: Sun Nov 16, 2008 7:41 pm
All the stage does is stick the two pieces together and then run it.chulett wrote:Split it up so that a part without parameters is in the Command box and the rest (the bit with parameters) is in the Parameter box. All the stage does is stick the two pieces together and then run it.
The only 'trick' to know is when the very first bit (typically a path to a script) is a parameter, then what you do is put "ksh" or "sh" in the command box and everything else in the parameter box.
Problem solved.
when the above sentence is true, then why do we need two boxes(command , parameters) in the exec command activity.
We can only have one box where we put the whole command along with parameters also can be combined with pipes.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Because that's how whoever write the Execute Command activity wrote it.
You may as well ask why we need to have the SELECT clause first in SQL, even though the FROM clause is parsed first.
Why can't we write
You may as well ask why we need to have the SELECT clause first in SQL, even though the FROM clause is parsed first.
Why can't we write
Code: Select all
FROM table SELECT columns WHERE condition;
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Charter Member
- Posts: 299
- Joined: Wed Nov 13, 2002 5:38 pm
- Location: USA
Actually I think a better question is why awk at all? Why two commands where one would do?
man test
-s FileName
Returns a True exit value if the specified FileName exists and has a size greater than 0.
Code: Select all
test -s #FileName#
-s FileName
Returns a True exit value if the specified FileName exists and has a size greater than 0.