Sponsored Content
Top Forums Shell Programming and Scripting Bash scripting question re: newlines Post 302125516 by retrovertigo on Thursday 5th of July 2007 05:33:57 PM
Old 07-05-2007
The result set that I wish to search will look like this:

Code:
Jul  3 23:12:14 mf04 postfix-mxmf/qmgr[6250]: CCB2825AE1C: from=<test@test.com>, size=2546, nrcpt=2 (queue active) 
Jul  3 23:12:14 mf04 postfix-mxmf/smtp[31012]: CCB2825AE1C: to=<user1@domain.com>, relay=some.server.address[192.168.30.201]:25, delay=8.2, delays=8.1/0.01/0/0.02, dsn=2.0.0, status=sent (250 low[1484]) 
Jul  3 23:12:14 mf04 postfix-mxmf/smtp[31012]: CCB2825AE1C: to=<user2@domain.com>, orig_to=<user1@domain.com>, relay=some.server.address[192.168.30.201]:25, delay=8.2, delays=8.1/0.01/0/0.02, dsn=2.0.0, status=sent (250 low[1484]) 
Jul  3 23:12:14 mf04 postfix-mxmf/qmgr[6250]: CCB2825AE1C: removed

Keep in mind that these results are stored in a variable called "results", and the IFS variable has been set to an empty string so that, when echo'ed, the above results will display with line breaks intact.

I want to filter out the lines with "postfix-mxmf/smtp" and just process those. For each line, I want to grab the email address and the "low[somenumber]". Both of these I can do with regexes, that's no problem. It's processing the output line by line that I'm having trouble with.

The end result is that, for each "postfix-mxmf/smtp" line, I grep another logfile for the email address and "low[somenumber]" and return a line that shows that the message was delivered, like so:

Code:
Jul  3 23:11:39 drd00 bingo[22660]: rfc2821: low[1484]: to=<user1@domain.com>, delay=0, status=sent 
Jul  3 23:11:39 drd00 bingo[22660]: rfc2821: low[1484]: to=<user2@domain.com>, delay=0, status=sent


Thanks for the help!

Last edited by retrovertigo; 07-05-2007 at 06:44 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash scripting help

hi all i'm trying to get a script working upon connection with pppd According to docu this happens ina clean environment with a couple of variables set, namely $1,$2,... To be able to execute the statements i included a path statement but i think i'm running into trouble with the variables -... (6 Replies)
Discussion started by: jimjones
6 Replies

2. Shell Programming and Scripting

bash scripting help!!

Hi, can anyone help me with my scrip please. I wanted do following tasks: 1. List all the directory 2. A STDIN to ask user to enter a directory name from listed directories 3. command to check if the directory exists( or a command to validate if the user entered a valid directory name)... (3 Replies)
Discussion started by: eminjan
3 Replies

3. Homework & Coursework Questions

bash,scripting

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: i have to do this but i am confused, Create a file containing the bash functions which perform the... (1 Reply)
Discussion started by: CRAZYLITTLELOU
1 Replies

4. Shell Programming and Scripting

Bash scripting, question about a variable

Hey, So I've run into a problem, due to my limited knowledge of Bash scripting. Basically I've got a long script and I want to understand it before I even try and edit it. As long as I don't understand the script, I will not bother editing it. Anyway, the following variable confuses me... (5 Replies)
Discussion started by: abciscool
5 Replies

5. Shell Programming and Scripting

Preserving newlines when writing loops on the command line in bash

Dear All, I have a question that's been difficult to get an answer to. I often write command line loops, e.g. find files, print name, grep for term, apply sed, etc I use both zsh and bash. When I write a loop e.g. for line in `more myfile.txt` > do > echo $line > done but... (2 Replies)
Discussion started by: JohnK1
2 Replies

6. Shell Programming and Scripting

Bash scripting question

have a script that calls child scripts depending on conditions. All of the child scripts source in a common file that contains shared functions. At the moment each script has to source this file itself, is there a way for the master script to automagically source the file for them? For... (3 Replies)
Discussion started by: redman
3 Replies

7. Shell Programming and Scripting

bash scripting

same script: 1- i am using grep to find a string called: tinker panic 0 in a file /etc/ntp.conf if the string is not there, i want to add the strings in /etc/ntp.conf file in the first line of the file. if not do nothing or exit. 2- also i want to add # in front of the following lines in... (0 Replies)
Discussion started by: lamoul
0 Replies

8. Shell Programming and Scripting

Beginner Bash Scripting Question

Hello, I am new to Linux and studying to become a Unix System Admin. I am taking a course in which I was practicing creating a bash script to ping a particular IP address. The script can be found below: #/bin/bash echo "Enter the IP address" read ip if then ping -c 1 $ip if ;... (3 Replies)
Discussion started by: shah9250
3 Replies

9. Shell Programming and Scripting

Total Noob BASH scripting question

Hello All, I have a file of ip addresses called activeips.txt What I'm trying to do is run a simple bash script that has a loop in it. The loop is a cat of the IP addresses in the file. The goal is to run 2 nmap commands to give me outputs where each address in the list has an OS... (11 Replies)
Discussion started by: Dirk_Pitt
11 Replies
cmannotifyd(8)						     CMAN Notification Daemon						    cmannotifyd(8)

NAME
cmannotifyd - CMAN Notification Daemon SYNOPSIS
cmannotifyd [-f] [-d] DESCRIPTION
The cmannotifyd daemon talks to CMAN and provides a mechanism to notify external entities about cluster changes. CMAN dispatches 3 kind of notifications: - CMAN_REASON_TRY_SHUTDOWN when cman requests to all clients if it is allowed to shutdown. - CMAN_REASON_STATECHANGE when cman detects a node joining or leaving the cluster. - CMAN_REASON_CONFIG_UPDATE when a configuration change event has been detected/requested. These notifications are then dispatched to the shell script cman_notify in the environment variable CMAN_NOTIFICATION. cman_notify will then execute all the scripts in the configured notification directory (default: /etc/cluster/cman-notify.d) passing a very minimal set of envvars including, of course, the CMAN_NOTIFICATION= type. The execution order is set by the filename as shown by "LC_ALL=C ls -las". cmannotifyd logs are stored in the default log file (/var/log/cluster/cmannotifyd.log). cman_notify logs are stored in the default log file (/var/log/cluster/cman_notify.log). By default the output from the scripts executed by cman_notify is redirected to /dev/null. Users can either set CMAN_NOTIFICATION_DEBUG=1 in their environment or set proper debug configura- tion in cluster.conf to redirect scripts output to the cman_notify log file. NOTES
cmannotifyd does not block on cman_notify nor check the exit status of the script. Notifications are dispatched in the same order as they arrive, one by one. CMAN_REASON_TRY_SHUTDOWN is passed to scripts for information only, they can not influence cman's decsion about whether or not to shut down. CMAN_REASON_STATECHANGE also implies CMAN_NOTIFICATION_QUORUM exported in the environment. CMAN_NOTIFICATION_QUORUM will be set to 1 (when the node is part of a quorate cluster) or 0 (otherwise). A template for cman_notify scripts can be found in the doc/ directory. OPTIONS
-f Run in the foreground (do not fork / daemonize). -d Enable debug output. November 2008 cmannotifyd(8)
All times are GMT -4. The time now is 02:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy