- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: send mail immediately when output arrives in a...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2012 08:14 AM
11-15-2012 08:14 AM
Hi guys ,
i have the following awk script which gives me o/p as desired ,
awk '
/Start of shutcons/, /End of CI0251/ {
if ($2 == "End" && $3 == "of" && $NF != 0) {
# if RC != 0, print stop line
print "job", $4, $(NF-2), "=", $NF
}
} ' abc.log > failures.log
if [ -s failures.log ]; then
mailx -s "subject" zxcv@company.example < failures.log
fi
rm -f failures.log
it fills failures.log with RC codes !=0 when shutcon job is started and before CI0251 job.
Now my problem is i want to fire a mail immediately when line number 1 gets o/p say for ex:
job xyz RC=12 ( it must send me a mail )
Afetr 2 min whan another line comes say for ex:
job tes RC=64 ( it must send me a mail )
Note here i shuld be getting 2 different mails with a single line only.
i.e it must flush earlier mailed line.
abc.log file is getting updated throughout day.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2012 10:13 AM
11-15-2012 10:13 AM
Re: send mail immediately when output arrives in a file
There are several ways to do this.
You could redirect awk's stdout to a named pipe. Then have another script read the pipe and send mail for each line.
(Or you could have coprocesses instead of that named pipe.)
Or you could replace that print by a open-print-close to a file. And then invoke the system function to mail that file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2012 09:17 PM
11-15-2012 09:17 PM
Re: send mail immediately when output arrives in a file
>Or you could replace that print by a open-print-close to a file. ...
Actually it is simpler than that:
awk '
BEGIN { mail_it = "mailx -s \"subject\" zxcv@company.example" }
/Start of shutcons/, /End of CI0251/ {
if ($2 == "End" && $3 == "of" && $NF != 0) {
# if RC != 0, print stop line
print "job", $4, $(NF-2), "=", $NF | mail_it
close(mail_it)
}
}' abc.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2012 06:36 PM
11-16-2012 06:36 PM
Solution>abc.log file is getting updated throughout day.
I assume you know you still need to use something like Laurent's solution in your other topic:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2012 02:05 AM
11-22-2012 02:05 AM
Re: send mail immediately when output arrives in a file
Thanks a ton