Sponsored Content
Top Forums Shell Programming and Scripting Help with Email Status shell script Post 302489170 by unimaxlin on Wednesday 19th of January 2011 04:49:15 PM
Old 01-19-2011
Help with Email Status shell script

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
-----------------------
Code:
#!/bin/bash
a=`date | cut -d " " -f2,2,3`
cat /var/log/maillog |grep "$a" |grep -E -e 'deferred|bounced' >> /tmp/mailer
for i in `cat /tmp/mailer`
do
address=`echo $i|awk -F " " '{print $7}' /tmp/mailer`
result=`echo $i|awk -F " " '{print $12}' /tmp/mailer`
reason=`echo $1|awk -F " " '{print $17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$28,$29}' /tmp/mailer`
echo "$address $result $reason"
done

Present output
----------------------------
the email send to=<mhillers@bellsouth.net>, status=deferred talk to me: 521-75.126.169.21 blocked by ldapSmilieu=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

I want and output Like this any Ideas

mhillers@bellsouth.net status=deferred Error - for abuse
timber'lee@timberlee.com status=deferred timeout
apache@bikepartsusa.com email account that you tried to reach does not

---------- 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 ldapSmilieu=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))
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check the status and send an email with status

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)
Discussion started by: isingh786
3 Replies

2. Shell Programming and Scripting

status bar in shell script or perl

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)
Discussion started by: learnbash
2 Replies

3. Shell Programming and Scripting

return status after run the shell script

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)
Discussion started by: govindts
6 Replies

4. UNIX for Dummies Questions & Answers

Job Status for running shell script

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)
Discussion started by: Gussifinknottle
2 Replies

5. Shell Programming and Scripting

how to suppress the status of fork in shell script

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)
Discussion started by: Arun_Linux
10 Replies

6. Shell Programming and Scripting

Script to email status

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)
Discussion started by: khchong
8 Replies

7. Shell Programming and Scripting

Help....script check status if see something then send email

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)
Discussion started by: dotran
6 Replies

8. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

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)
Discussion started by: ketanraut
9 Replies

9. Shell Programming and Scripting

Shell script has to run until the status value is updated

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)
Discussion started by: sumanmca2006
7 Replies

10. UNIX for Beginners Questions & Answers

Automation script for email alert when a job get complete with status successful.

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)
Discussion started by: Rehan Ahmad
1 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a file name containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 09:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy