Sponsored Content
Top Forums Shell Programming and Scripting Generate script perl mail log not work Post 302526209 by puka on Monday 30th of May 2011 11:42:14 PM
Old 05-31-2011
Quote:
Originally Posted by rdcwayx
Not good solution, but simple.

Code:
 egrep -o "sasl_username=.*|from=.*|to=.*" infile  |awk '/sasl_username=/{username=$1;i=0}
/from=/{from=$1}
/to=/&&++i<=3{print username, from, $1}' OFS="|" |awk '{gsub(/sasl_username=|from=|to=|<|>|,/,"")}1'
 
 
account1@domain1.com|sender2@domain2.com|brian5841@yahoo.com
account1@domain1.com|sender2@domain2.com|brooke_leee@yahoo.com
account1@domain1.com|sender2@domain2.com|c0809@yahoo.com
account1@domain1.com|sender2@domain2.com|brian5841@yahoo.com
account1@domain1.com|sender2@domain2.com|brooke_leee@yahoo.com
account1@domain1.com|sender2@domain2.com|c0809@yahoo.com

I generate code but not want out put.

sasl_username=account1@domain1.com
from=<account1@domain1.com>,
from=<account1@domain1.com>,
to=<account1@domain1.com>,
from="avel88@hotmail.com";
from=avel88@hotmail.com,
from=avel88@hotmail.com,
from=<avel88@hotmail.com>,
to=<account2@domain2.com>,
from=<seo1@co.za>
from=<avel88@hotmail.com>,
to=<iam@hotmail.co.th>,
to=<da@hotmail.com>,
to=<account3@domain3.com>,
to=<user1@domain3.com>,
to=<user2@domain3.com>,
to=<user3@domain3.com>,
to=<user4@domain3.com>,

my code

awk ' BEGIN { FS="[" } /client=/ { print $3 } ' < /var/log/mail.log | sed s/]//

22.13.23.200, sasl_method=LOGIN, sasl_username=account1@domain1.com, ........... , .............
33.14.55.243
55.154.173.75
66.15.219.1, sasl_method=LOGIN, sasl_username=account1@domain2.com, ........... , .............
14.12.138.57, sasl_method=LOGIN, sasl_username=account1@domain3.com, ........... , .............

I can not show , ....from=<....... , .....to=<........ , .....to=<........ , .....to=<........ (to 3 account)

or

, ....from=<....... , .....to=<........ (to 1 account)

---------- Post updated at 10:42 PM ---------- Previous update was at 10:37 PM ----------

Quote:
Originally Posted by rdcwayx
Not good solution, but simple.

Code:
 egrep -o "sasl_username=.*|from=.*|to=.*" infile  |awk '/sasl_username=/{username=$1;i=0}
/from=/{from=$1}
/to=/&&++i<=3{print username, from, $1}' OFS="|" |awk '{gsub(/sasl_username=|from=|to=|<|>|,/,"")}1'
 
 
account1@domain1.com|sender2@domain2.com|brian5841@yahoo.com
account1@domain1.com|sender2@domain2.com|brooke_leee@yahoo.com
account1@domain1.com|sender2@domain2.com|c0809@yahoo.com
account1@domain1.com|sender2@domain2.com|brian5841@yahoo.com
account1@domain1.com|sender2@domain2.com|brooke_leee@yahoo.com
account1@domain1.com|sender2@domain2.com|c0809@yahoo.com

if out put

account1@domain1.com | sender2@domain2.com | brian5841@yahoo.com,brooke_leee@yaho...0809@yahoo.com

I wrtie code ?

Thank you very much
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Modify script to generate a log file

I've seen several examples of scripts in thise forum about having a script generate a log file. I have a script that is run from cron and that monitors a file system for a specfic filename(s) and then performs some actions on them. Normally I call this script from another script (which the one... (2 Replies)
Discussion started by: heprox
2 Replies

2. Shell Programming and Scripting

mail program on shell script didn't work, please advise.

Hi, everyone: I post a new thread because previous post may sink and I hope the new one can be caught by your eyes. I created a shell script and the script works fine. However, the mail program part on script didn't send email to my email box and it also didn't provide any traceable... (7 Replies)
Discussion started by: duke0001
7 Replies

3. Shell Programming and Scripting

Modify Perl script to work with txt - Permissions script

Hi I have this code, and i want work with a ls -shalR output in .txt What i need read to do this?? Where start? #!/usr/bin/perl # Allrights- A perl tool for making backups of file permissions # Copyright (C) 2005 Norbert Klein <norbert@acodedb.com> # This program is free... (1 Reply)
Discussion started by: joangopan
1 Replies

4. Shell Programming and Scripting

perl or bash script that will generate a higher than usual load

Hi, please advise what function in perl or system call in shell that will generate cpu usage that is higher than usual? I would like make such a script, to test a monitoring feature. TIA. Marc (1 Reply)
Discussion started by: marcpascual
1 Replies

5. Shell Programming and Scripting

sed script to generate hyperlinks refuses to work

Hi All, I'm new to the forum and not a programmer, but I'm writing a bash script to preprocess definitions of technical terms by inserting hyperlinks pointing to other pages in the glossary before the pages are posted to our server, using a standard naming convention for the pages. The... (3 Replies)
Discussion started by: markfgilliland
3 Replies

6. Shell Programming and Scripting

Monitor log file for a Error and generate the e-mail.

This is my log file and this is live log. Any abnormal error other than following I need to generate the email. Log path : /DER/app/admin/ABC/bdump/erg.log Current log# 2 seq# 103046 mem# 0: /ora2/oradata/ABC/redo02a.log Current log# 2 seq# 103046 mem# 1:... (1 Reply)
Discussion started by: hishanms
1 Replies

7. Shell Programming and Scripting

How to monitor log file for a Error and generate the e-mail ( Please help)

This is my log file and this is live log. Any abnormal error other than following I need to generate the email. Log path : /DER/app/admin/ABC/bdump/erg.log Current log# 2 seq# 103046 mem# 0: /ora2/oradata/ABC/redo02a.log Current log# 2 seq# 103046 mem# 1:... (7 Replies)
Discussion started by: hishanms
7 Replies

8. Shell Programming and Scripting

[Fixed Itself!] Sending mail form script using sSMTP does not work

I have installed sSMTP and set it up to use my gmail. Sending from cli does work fine: msg file:From: test@gmail.com To test2@gmail.com Subject: test post This is a test Executing from console:ssmtp -t < msg does work fine. But from script it does not work:#!/bin/sh ssmtp -t < msg... (0 Replies)
Discussion started by: Jotne
0 Replies

9. Shell Programming and Scripting

Perl: script to work with files with the same name in different directories

Hi All, I would like to use a Perl (not Bash) script to work with multiple files of the same name in different directories (all in the same parent directory). I tried to create a loop to do so, but it isn't working. My code so far: while (defined(my $file = glob("./*/filename.txt")) or... (1 Reply)
Discussion started by: elgo4
1 Replies

10. Shell Programming and Scripting

How can i make my cron/script to generate a log filename with timestamp in it ?

Hello Friends, I would like my script to display date timestamps in the file name for every script execution. Below is the scenario: (just for testing purpose) I scheduled a cron job, lets say it runs every 5 min and record/logs output in to a log file. 0,5,10,15,20,25,30,35,40,45,50,55 *... (5 Replies)
Discussion started by: System Admin 77
5 Replies
All times are GMT -4. The time now is 04:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy