|
Prev: losf equivalent in perl
Next: Define Variable Data Type
From: gopikrishnan.gunasekaran@gmail.com on 11 Feb 2006 05:44 Hi, The scenario is the awk command should check the second field of the output, if it is greater than 80 it should trigger an automatic email to me in this address, Help me to do this Regards, Gopi Krishnan
From: Janis Papanagnou on 11 Feb 2006 07:55 gopikrishnan.gunasekaran(a)gmail.com wrote: > Hi, > The scenario is the awk command should check the second field of the > output, if it is greater than 80 it should trigger an automatic email > to me in this address, Help me to do this > > Regards, > Gopi Krishnan > This has already been answered to you more generally in comp.lang.awk, where you would just have to replace the "/some content condition/" by your actual condition "length($2)>80". awk 'length($2)>80 { print "Some notification" | "mailx -s you(a)addr" }' You may also want to add an exit after the print|"mailx ..." statement. Janis
From: Ed Morton on 11 Feb 2006 19:26 Janis Papanagnou wrote: > gopikrishnan.gunasekaran(a)gmail.com wrote: > >> Hi, >> The scenario is the awk command should check the second field of the >> output, if it is greater than 80 it should trigger an automatic email >> to me in this address, Help me to do this >> Regards, Gopi Krishnan >> > > This has already been answered to you more generally in comp.lang.awk, > where you would just have to replace the "/some content condition/" by > your actual condition "length($2)>80". > > awk 'length($2)>80 { print "Some notification" | "mailx -s you(a)addr" }' I thought he meant to send email if $2 had a value greater than 80, not a length greater than 80: awk '$2>80 { print "Some notification" | "mailx -s you(a)addr" }' > You may also want to add an exit after the print|"mailx ..." statement. Hard to say. He also says to check the second field of "the output" whereas we've both provided solutions for the second field of the input, and using awk like this is obviously not a great way to just send email if you have one line with a second field with value greater than 80. It's hard to say what the OPs really trying to do.... Ed.
From: Xicheng on 11 Feb 2006 21:55 Ed Morton wrote: > Janis Papanagnou wrote: > > > gopikrishnan.gunasekaran(a)gmail.com wrote: > > > >> Hi, > >> The scenario is the awk command should check the second field of the > >> output, if it is greater than 80 it should trigger an automatic email > >> to me in this address, Help me to do this > >> Regards, Gopi Krishnan > >> > > > > This has already been answered to you more generally in comp.lang.awk, > > where you would just have to replace the "/some content condition/" by > > your actual condition "length($2)>80". > > > > awk 'length($2)>80 { print "Some notification" | "mailx -s you(a)addr" }' > I thought he meant to send email if $2 had a value greater than 80, not > a length greater than 80: > > awk '$2>80 { print "Some notification" | "mailx -s you(a)addr" }' > > > You may also want to add an exit after the print|"mailx ..." statement. > I'm just wondering why you would put this pipeline within 'awk'? is there any benefit from doing so?? I may do it separately otherwise.. awk '$2>80 { print "Some notification"}' | mail -s"length exceeds 80" you(a)addr Xicheng > Hard to say. He also says to check the second field of "the output" > whereas we've both provided solutions for the second field of the input, > and using awk like this is obviously not a great way to just send email > if you have one line with a second field with value greater than 80. > It's hard to say what the OPs really trying to do.... > > Ed.
From: Janis Papanagnou on 11 Feb 2006 22:08
Xicheng wrote: > Ed Morton wrote: >>Janis Papanagnou wrote: >>>gopikrishnan.gunasekaran(a)gmail.com wrote: >>> >>>>Hi, >>>>The scenario is the awk command should check the second field of the >>>>output, if it is greater than 80 it should trigger an automatic email >>>>to me in this address, Help me to do this >>>>Regards, Gopi Krishnan >>> >>>This has already been answered to you more generally in comp.lang.awk, >>>where you would just have to replace the "/some content condition/" by >>>your actual condition "length($2)>80". >>> >>>awk 'length($2)>80 { print "Some notification" | "mailx -s you(a)addr" }' >> >>I thought he meant to send email if $2 had a value greater than 80, not >>a length greater than 80: >> >>awk '$2>80 { print "Some notification" | "mailx -s you(a)addr" }' >> >>>You may also want to add an exit after the print|"mailx ..." statement. > > I'm just wondering why you would put this pipeline within 'awk'? is > there any benefit from doing so?? I may do it separately otherwise.. > > awk '$2>80 { print "Some notification"}' | mail -s"length exceeds 80" > you(a)addr There is a difference! With the pipe command within awk there won't be any mail sent if nothing matches, while in your code an empty mail will be created. Janis |