Like many Unix shops, Our systems send Email alerts whenever things break. I have been tasked with writing a shell script to get the email alerts from Sendmail, extract the Date / Time, From, Subject, and message text from the emails and punch them into a MySQL DB. This will then be parsed and used to generate Error Stats and SLA reports.
My problem is I can't seem to find any info or blurb of code on how to extract this info from a Sendmail using a shell script, and my O'Rielly Sendmail book is MIA.
Anyone out there have any expierience with this and/or could guide me in the right direction?
I need to parse the individual emails as they come in, but I am not sure how to extract the data from sendmail. I could have the emails go to a special account, but I dont know how to get the need data out of the emails. If the email can be dumped to a file I could do it that way, but I am not as familiar with Sendmail as I would like.
I think perl can handle that, something like :
I took this example from random google page, therefore it does not describe exactly the task you want to achieve, but
open the file, parse the content as defined in regexp and output it in a different file. Then INSERT this in SQL. Also, you need to know where the sendmail store those e-mails, if this is one e-mail, or a single flat file, my example is "/var/spool/mail/root"
This is just a suggestion, there are more efficient ways to achieve that, I believe that someone will post another opinion soon.
Edit : Actually, I believe that Python would be more elegant way to solve this, but i'm not really expirienced with it, ghostdog74 is one of Python's experts here.
Hope this helps.
This is my input file:
a|b|c(ef)|g|h(km)|p
My output file should look like:
a|b|ef|g|km|p
That is, pipe is the delimiter. The data within pipe must be displayed as it is but if it encounters any data within parentheses, then only the data within parentheses has to be displayed ( the data... (2 Replies)
I am trying to compare the data in lines 3 & 5 to see if they match up to the '-S570' (see first code set, all proprietary information has been removed from code set)
spawn telnet
Trying ...
Connected to CA-LOS1234-ASE-S570.cl .
Escape character is '^]'.
CA-LOS1234-ASE-S570
Username: ... (1 Reply)
I have a txt file of the following format
>ab_
qwerty
>rt_
hfjkil
>Ty2
hglashglkasghkf;
>P2
aklhfklflkkgfgkfl
>ui_
vnllkdskkkffkfkkf
>we32
vksksjksj;lslsf'sk's's
....
.....
I want to split this big file based on the header (>) (5 Replies)
Hi,
I have one file, say file 1, that has data like below where 19900107 is the date,
19900107 12 144 129 0.7380047
19900108 12 168 129 0.3149017
19900109 12 192 129 3.2766666E-02
... (3 Replies)
Hi
I have the following data :
<Cell id="34A" ref="ds:/BTS:34/Cells/Cell:34A"/>
<Cell id="34B" ref="ds:/BTS:34/Cells/Cell:34B"/>
<Cell id="34C" ref="ds:/BTS:34/Cells/Cell:34C"/>
I would like to print this data in the following format :
BTS:34 Cell:34A.I'm... (9 Replies)
I have attached a txt file, what I would like to be able to do is:
1. Extract Data from Columns labeled E/N and Ko into a new file
2. Then in the new file I would like to be able to plot E/N on the X axis and Ko on the y axis.
3. Lastly I would like to be able to extract multiple data sets and... (6 Replies)
Given the following text in a file named extract.txt:
listenPort:=25
smtpDestination:=2
enableSSL:=
I am trying to extract only the value 2 following smtpDestination:=
Someone had suggested I use:
sed -e "s/^smtpDestination:=\(.*\)$/\1/" extract.txt
but this returns:
listenPort:=25
2
... (2 Replies)
Hi All
I have one file aa.txt like this
Change 172453 on 2006/04/26 10:45:45 by cm@cm-ixca-cm-build23 'cmbuild: ixweb-3.10.28.110 '
Change 172362 on 2006/04/26 08:58:47 by cm@cm-ixca-cm-build23 'build failed: ixweb-3.10.28.109'
Change 172299 on 2006/04/26 07:39:08 by... (1 Reply)
How do I delete text in each line from the first character up to a certain pattern, ie. 'qmuser.' and then delete from the next occurence of a dot to the end of the sentence
For example: -
LTSB Renewal Notice Travel Pack --- d \qmaster\spool1\qmuser.8664_LM245_20031216094308.ps.0
From this... (7 Replies)
I'm a newbie trying to update an old sendmail 8.6 to 8.12.3
ftp'ed sendmail.org and got sendmail.8.12.3.tar.gz
file size matches but when i:
tar xvf sendmail.8.12.3.tar.gz
i get:
tar: directory checksum error
tried getting others... ie. 8.12.2...
ftp'ed using binary and saved in... (1 Reply)