I have written a bash script to to sort the data from logs i need some help in printing the outputs , i dont have much ideas in bah scripting.
Sample script
-----------------------
Present output
----------------------------
the email send to=<mhillers@bellsouth.net>, status=deferred talk to me: 521-75.126.169.21 blocked by ldapu=rblmx,dc=att,dc=net 521 Error - for abuse.
the email send to=<timber'lee@timberlee.com>,status=deferred timeout (#4.4.2) (in reply to end of DATA command))
the email sendto=<apache@bikepartsusa.com>,status=bounced The email account that you tried to reach does not Please try
---------- Post updated at 04:49 PM ---------- Previous update was at 04:44 PM ----------
I am sending the log format i have
/var/log/maillog
Jan 19 12:21:10 bikepartsusa postfix/smtp[6054]: 4DD75D4C45: to=<rfgoodman@bellsouth.net>, relay=gateway-f2.isp.att.net[207.115.11.16]:25, delay=155893, delays=155892/0.01/0.2/0, dsn=4.0.0, status=deferred (host gateway-f2.isp.att.net[207.115.11.16] refused to talk to me: 521-75.126.169.21 blocked by ldapu=rblmx,dc=att,dc=net 521 Error - Blocked for abuse. Contact abuse_rbl@abuse-att.net.)
Jan 19 12:29:30 bikepartsusa postfix/smtp[6756]: 57986D4C53: to=<apache@bikepartsusa.com>, relay=ASPMX.L.GOOGLE.com[74.125.159.27]:25, delay=3.5, delays=0.01/0/0.3/3.1, dsn=5.1.1, status=bounced (host ASPMX.L.GOOGLE.com[74.125.159.27] said: 550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1 'This Gmail user does not exist...' - Gmail Help g9si15796109anh.79 (in reply to RCPT TO command))
Jan 19 12:21:31 bikepartsusa postfix/smtp[6055]: 9E874D4C43: to=<timber'lee@timberlee.com>, relay=nullmx.timberlee.com[209.181.247.105]:25, delay=423999, delays=423979/0.01/0.08/20, dsn=4.0.0, status=deferred (host nullmx.timberlee.com[209.181.247.105] said: 451 timeout (#4.4.2) (in reply to end of DATA command))
OK you should probably start by extracting the 3 data fields you need from the log (toemail, status and errorstr):
It then looks like you want to suppress display of the bounced status and transpose/convert the errorstr.
The errorstr seems to be quite free format and I suspect there are a many more types of errorstr than you example data lists so I've left the string as it appears in the original logfile. Perhaps you can give us some more indication on what should happen with this string.
i am getting an error when i execute this directly can
[root@freebsd:/root 01:42]sh test2.sh
awk: calling undefined function gensub
input record number 1, file /var/log/maillog
source line number 3
---------- Post updated at 03:26 PM ---------- Previous update was at 03:17 PM ----------
My present out put is like this i need it to setup the script in a single line
to=<mhillers@bellsouth.net>,
to=<skimmels@bellsouth.net>,
to=<rfgoodman@bellsouth.net>,
status=deferred
status=deferred
status=deferred
timeout (#4.4.2) (in reply to end of DATA command))
The email account that you tried to reach does not Please try
#5.1.0 Address rejected www@www.unitedlabsupplies.com (in reply to RCPT TO command))
the present output will not help me it similar to log i need only email id status the a small reason
present output
------------------- mhillers@bellsouth.net deferred host gateway-f2.isp.att.net[207.115.11.16] refused to talk to me: 521-75.126.169.21 blocked by ldapu=rblmx,dc=att,dc=net 521 Error - Blocked for abuse. Contact abuse_rbl@abuse-att.net. www@www.unitedlabsupplies.com bounced host smtp.secureserver.net[216.69.186.201] said: 550 #5.1.0 Address rejected www@www.unitedlabsupplies.com (in reply to RCPT TO command) apache@bikepartsusa.com bounced host ASPMX.L.GOOGLE.com[74.125.159.27] said: 550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1 ogle.com/support/bin/answer.py?answer=6596]'This Gmail user does not exist...' - Gmail Help g9si15796109anh.79 (in reply to RCPT TO command)
Thank`s for great help i need to parse a few more log files
present output
---------------------- drlarocque@juno.com status=deferred host mx.dca.untd.com[64.136.44.37] refused to talk to me: 550 Access denied...181d58d961d8bdbd296888915959596869c55d0878294c2dbd6d6c5d25ac5d0d55a1d5550decec78b1ecf9852d1 92165196d01080c016d018d4c... scofieldserco@juno.com status=deferred delivery temporarily suspended: host mx.dca.untd.com[64.136.44.37] refused to talk to me: 550 Access denied...4f5135b57185a9a96160c1a1bd80bda1b9053d592061758da9b0643dcd103d95e984e5e995909020e190241d8d0 0f1f000b0f959c9f9b0f95075... pgstore@post-gazette.com status=deferred host mailrelay3.post-gazette.com[64.206.167.180] said: 552 Rejected by CA Gateway Security [scm-3.post-gazette.com] (ASF-99) (in reply to end of DATA command)
pgstore@post-gazette.com status=deferred host mailrelay3.post-gazette.com[64.206.167.180] said: 552 Rejected by CA Gateway Security [scm-3.post-gazette.com] (ASF-99) (in reply to end of DATA command)
biostockroom@umbc.edu status=deferred host mxin.umbc.edu[130.85.12.6] said: 451 4.3.2 Greylisting. Try back in a while. (in reply to RCPT TO command)
i would like to parse it
---------------------------------
i wan to parse a few more logs
biostockroom@umbc.edu status=deferred Greylisting
pgstore@post-gazette.com status=deferred host Rejected by CA Gateway Security
scofieldserco@juno.com status=deferred delivery temporarily suspended
drlarocque@juno.com status=deferred host refused to talk to me:
Guyz,
Please let me know about script which is to be sending an automatic email to particular mail id's when a monotoring job get complete with status successful. (1 Reply)
Hi All,
Need some help like how to exit from the script after updating the column in data base.
db2 connect to DB
STATUS=$(db2 "SELECT STATUS FROM XYZ )
echo $STATUS
Initially the status value will be '4' or 'NOT YET RUN'.
The Shell script has to run until the status value is updated... (7 Replies)
Hi,
I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help..
i am using below command to run script
nohup system_traps.sh &
but in some... (9 Replies)
autorep -m bogus
Machine Name Max Load Current Load Factor O/S Status
___________ ________ ___________ ______ ________ ______
bogus --- --- 1.00 Sys Agent Online
Status
______
Online
Offline
Missing
Unqualified
The "Status" always "Online". I like create a script execute run... (6 Replies)
Hi,
I have few processes in the server continuous run few jobs, each of the process will generate a log file which detailing when its jobs are completed.
the logfile will has the name something like this, result1.log, result2.log, result3.log,.... result10.log, result11.log, result12.log.......... (8 Replies)
When command is executed by forking, the console displays the status of that command. I want to suppress it.. how to do it ?
Example:
var1=`date` &
echo "hello world";
output:
hello world
+ Done var1=`date`
I want to suppress the second line "+ Done var1=`date`".
I... (10 Replies)
Hello,
I am running a shell script whose execution often takes several hours to complete. Is there way I can get some kind of status update as the job is running? Something as simple as the start and the current time stamp.
Thanks,
Gussi (2 Replies)
Hello, I wanted to delete all files which are placed 14 days back. Here is my below script. My script works very well and it deletes all files 14 days back.
I wanted to display message incase if the delete script is not successful. The below script returns always successful. But the directory... (6 Replies)
How To Generate different different progress bar in shell script?
like we install some software it show us progress, like we install RPM that also show us progress.
Thanks,
Bash (2 Replies)
Hi,
We have a text file which has the following data.
ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183
7~U~00200~000011258~0~P~<
GS~FA~EE05J~U1CAD~051227~1831~000011258~X~002002
ST~997~0001
AK1~SH~247
AK2~856~2470001
AK5~A
AK2~856~2470002
AK5~A... (3 Replies)