|
|
mail command within awk #2
Hi ,
Shall we run the mail command within awk based on some condition. Can
anyone help me in this.
Thanks & Regards,
Gopi
|
|
0
|
|
|
|
Reply
|
gopikrishnan.gunasekaran (19)
|
2/9/2006 6:03:04 PM |
|
gopikrishnan.gunasekaran@gmail.com wrote:
> Hi ,
>
> Shall we run the mail command within awk based on some condition. Can
> anyone help me in this.
>
> Thanks & Regards,
> Gopi
>
It isn't clear what you're asking. If, for example, you're asking how to
execute the UNIX mailx command from within awk, the responses you'd get
would be:
a) There's probably a better way to achieve your goal than to do that.
b) The answer will be platform-specifc and so the question should be
asked in a platform-specific newsgroup, e.g. comp.unix.shell
Regards,
Ed.
|
|
0
|
|
|
|
Reply
|
Ed
|
2/9/2006 11:47:47 PM
|
|
gopikrishnan.gunasekaran@gmail.com wrote:
> Hi ,
>
> Shall we run the mail command within awk based on some condition. Can
> anyone help me in this.
>
> Thanks & Regards,
> Gopi
>
There's the possibility to pipe any string to an external command, and
before that you may also extract subject and mail address information...
/some subject condition/ { subject = $4 }
/some recipient condition/ { addrlist = addrlist " " $1 }
/some content condition/ { print $5 $6 | "mailx -s " subject addrlist }
If, OTOH, just the mail body is to be defined by the awk data then you
could put that shell interface to the shell level...
awk '/some content cond/ { print $5 $6 }' yourdata | mailx -s subj x@y.z
Janis
|
|
0
|
|
|
|
Reply
|
Janis
|
2/10/2006 12:41:25 AM
|
|
On Thu, 9 Feb 2006, gopikrishnan.gunasekaran@gmail.com wrote:
> Shall we run the mail command within awk based on some condition. Can
> anyone help me in this.
I have some scripts who mail me (once) if they detect some condition
(repeatedly). E.g. a crontab script who periodically runs ps and informs
me of any new process started by an unusual user.
When I detect the condition I do something like this (the counter ne is
initialized at zero)
s="my own specific message on the condition"
ne++
mail(s)
where mail(s) is a function defined at the end of the file, which
appends the string to a file (fil3 is initialized at beginning)
function mail(string) { print string >> fil3 }
The way I do the mailing is the following invocation (at the end of the
main clause ... such scripts for me have usually just a BEGIN clause)
if (ne > 0) system("/usr/bin/mailx -s 'mysub' myaddr < "fil3" >/dev/null")
where mysub is a string which goes in the subject, and myaddr is my own
e-mail address.
--
----------------------------------------------------------------------
nospam@mi.iasf.cnr.it is a newsreading account used by more persons to
avoid unwanted spam. Any mail returning to this address will be rejected.
Users can disclose their e-mail address in the article if they wish so.
|
|
0
|
|
|
|
Reply
|
LC
|
2/16/2006 1:20:22 PM
|
|
|
3 Replies
289 Views
(page loaded in 0.065 seconds)
Similiar Articles: Awk Script with multiple condition... - comp.lang.awkmail command within awk - comp.lang.awk Hi , Shall we run the mail command within awk based on some condition. ... scripts who mail me (once) if they detect some condition ... GNU-awk bug in sub()/gsub() - comp.lang.awkmail command within awk - comp.lang.awk GNU-awk bug in sub()/gsub() - comp.lang.awk Bug with Solaris nawk? - comp.lang.awk mail command within awk - comp.lang.awk GNU-awk ... processing output of external command - comp.lang.awkmail command within awk - comp.lang.awk processing output of external command - comp.lang.awk... calling the "ldapsearch" command directly from awk ... Strange df and du behavior - comp.unix.solarisGNU-awk bug in sub()/gsub() - comp.lang.awk Bug with Solaris nawk? - comp.lang.awk mail command within awk - comp.lang.awk GNU-awk bug in sub()/gsub() - comp.lang.awk ... How to combine two awk commands - comp.lang.awkHi, I am piping the output from one awk command ... 06 Apr 2005 12:43:28 GMT£¬Jonny <www.mail@ntlworld.com> write: > Hi, > > I am piping the output from one awk command ... Run awk95 using VBA Shell(...) in Excel 2000 - comp.lang.awk ...--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http ... AWK command inside the shell script - comp.lang.awk Run awk95 using VBA Shell(...) in Excel ... Capture windows command return code to variable in awk script ...-- To reply by e-mail, please remove the extra dot ... Help to 'pretty'; replace WITHIN file without TEMP file?? - comp ..... test4.txt with the command awk ... Simple XML processing in AWK - comp.lang.awk... questions about doing some simple XML scanning in AWK. ... On Jun 13, 4:38=A0am, jh...@mail.avcnet.org wrote ... Furthermore, ">" is a valid XML character *inside* a tag ... script for telnet on port 25 - comp.lang.awk... this (talking SMTP through telnet within ... for telnet on port 25 - comp.lang.awk I need to do this > for multiple mail ... to any server and put the following commands ... begginer: setting the exit status - comp.lang.awk3) The part within the END could just be "exit flag". ... begginer: setting the exit status - comp.lang.awk External command ... To set 8bitmime or not? - comp.mail.misc begginer ... mail command within awk - Application Forum at ObjectMix.comHi , Shall we run the mail command within awk based on some condition. Can anyone help me in this. Thanks & Regards, Gopi UNIX Basics : Examples with awk: A short introductionThe key question is whether this awk command ... can be done by processing the mail spool with the awk ... With the GNU version of awk, is possible include them within the awk ... 7/23/2012 9:24:54 PM
|
|
|
|
|
|
|
|
|