Sponsored Content
Top Forums Shell Programming and Scripting Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH Post 302994229 by RobbieTheK on Monday 20th of March 2017 03:00:38 PM
Old 03-20-2017
Linux Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works:
Code:
LOCAL_CONFIG
#
Kcheckaddress regex -a@MATCH
    [a-zA-Z_0-9.-]+<@[a-zA-Z_0-9-]+?\.+[a-zA-Z_0-9.-]+?\.(us|info|to|br|bid|cn|ru)
LOCAL_RULESETS
SLocal_check_mail
# check address against various regex checks
R$*                             $: $>Parse0 $>3 $1
R$+                             $: $(checkaddress $1 $)
R@MATCH                         $#error $: "553 Your Domain is Blocked for Unsolicited Mail"

So we are blocking anything@subdomain.domain.us but not anything@domain.us. I'd like to add exclusions for cities and schools so to allow user@ci.somedomain.us and user@subdomain.[state].us. (note that [state] means 1 of the 50 states including DC).

This regex with negative lookahead syntax is not working (using CA for California as a test):
Code:
(?!.*\@ci\..+?\.us$)(?!.*\@*\..+?\.ca.us$)([a-zA-Z_0-9.-]+@[a-zA-Z_0-9-]+?\.+[a-zA-Z_0-9.-]+?\.(us)$)

I get this error:
Code:
sendmail -bt
/etc/mail/sendmail.cf: line 199: pattern-compile-error: Invalid preceding regular expression

I'm pretty sure that sendmail's R & K commands do not support negative look-aheads. So if anyone can help re-write the regex in a sed-friendly format I'd be grateful! Here is a link to K command switches. Any suggestions on how to get the negative lookahead to work in sendmail?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

regex to match basename

Hi Can somebody please help me know how do i match the basename using a regular expression using posix standard in shell script suppose i want to match /u01/Sybase/data/master.dbf the result should be master.dbf as i want to match everything after the last / regards (8 Replies)
Discussion started by: xiamin
8 Replies

2. UNIX for Advanced & Expert Users

Regex to match IP address

What do you think of this regex to match IP address? I have been reading up on regex and have seen some really long ones for IP. Would this fail in any scenarios? (+\.){3}* (5 Replies)
Discussion started by: glev2005
5 Replies

3. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

4. Shell Programming and Scripting

PCRE negative lookahead

I have read many tutorials and cannot get this to work. I need to use pcre (because that is what the library in the software we are using uses) and pcregrep everything except /home from the /etc/fstab pcregrep '(?!/home)' /etc/fstab It returns the entire fstab (This is on a RHEL5... (1 Reply)
Discussion started by: insania
1 Replies

5. Shell Programming and Scripting

Regex: Get the word before match

Hi Input: MYTEXT.aa.bb cc.MYTEXT.aa.bb ee.dd.cc.MYTEXT.aa.bb cc.NOTEXT.a.b Output: <empty> cc cc <empty> I would like to use a regex to extract the last word before MYTEXT without the dot (2 Replies)
Discussion started by: chitech
2 Replies

6. Shell Programming and Scripting

Regex to match only first occurence with grep

Hello to all, How would be the correct regex to match only the first occurence of the pattern 3.*6. I'm trying with 3.*6 trying to match only 34rrte56, but with my current regex is matching 4rrte567890123456789123powiluur56. And if I try with ? doesn't print anything echo... (6 Replies)
Discussion started by: Ophiuchus
6 Replies

7. Shell Programming and Scripting

Only Regex pattern match help

Hi We have a tool to monitor logs in our environment. The tool accepts log pattern match only using regex and I accept I am a n00b in that:confused:. I had been banging my head to make it work without much success and at last had to turn on to my last option to post it here. I had got great... (2 Replies)
Discussion started by: radioactive9
2 Replies

8. UNIX for Advanced & Expert Users

Regex to match Exact port number (netstat command)

Hi All, We have this regex:\\*.*?(.600).*?.(LISTEN|ESTABLISHED) OS = Solaris 10 The purpose of this regex is to match the ports in output of "netstat -an" and report if any ports between 6000-6009 are getting used. The only problem is if I have something like this (sample output as... (6 Replies)
Discussion started by: sk2code
6 Replies

9. Shell Programming and Scripting

Regex negative look and bash script

My script have to read logfile, and take some action, if in pattern are strings: 1) exit 0 strings pattern ... "INF - Status"... success 2) exit 1 (! as not) strings pattern ... "INF - Status"... !success Simple example, what works #!/bin/bash tail -f regex.log | while read LOGLINE ... (7 Replies)
Discussion started by: kvaikla
7 Replies

10. Shell Programming and Scripting

Mailq regex match

Hi, # mailq | awk '{match($0, /quota/)} {print $0}' | head -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- 9A6A7DE117E 84309 Sat Sep 30 14:14:50 alerts-noreply+xxxxx=xxx.sg@xxx.xx.xxx (host alt1.gmail-smtp-in.l.google.com said: 452-4.2.2 The email account that you... (2 Replies)
Discussion started by: ashokvpp
2 Replies
SVNNOTIFY(1p)						User Contributed Perl Documentation					     SVNNOTIFY(1p)

Name
       svnnotify - Subversion activity notification

Usage
	 svnnotify --repos-path "$1" --revision "$2" [options]

Options
	 -p --repos-path PATH	      Path to the Subversion repository. Required.
	 -r --revision REVISION       Commit revision number. Required.
	 -t --to ADDRESS	      The notification destination email address.
				      Required unless --to-regex-map.
	 -x --to-regex-map TO=REGEX   A mapping between a destination email address
				      and a regular expression to match against the
				      directories affected by the commit. Required
				      unless --to or --to-email-map.
	    --to-email-map REGEX=TO   The inverse of --to-regex-map: Map a regular
				      expresion to an email address. Required unless
				      --to or --to-regex-map.
	 -f --from ADDRESS	      Email address to use in the From header.
	 -D --user-domain DOMAIN      Domain name to append to the username to
				      complete the email address in the From header.
	 -l --svnlook SVNLOOK	      Location of the svnlook executable.
	 -s --sendmail SENDMAIL       Location of the sendmail executable.
	 -E --set-sender	      Set the envelope sender to the from address.
	    --smtp ADDRESS	      Address for an SMTP server.
	    --smtp-user USERNAME      Username for authenticating to a SMTP server.
	    --smtp-pass PASSWORD      Password for authenticating to a SMTP server.
	    --smtp-authtype AUTHTYPE  Type of SMTP authentication.
	 -c --encoding ENCODING       The character encoding for reading and writing
				      data.
	    --svn-encoding ENCODING   The character encoding of the log message and
				      the repository files.
	    --diff-encoding ENCODING  The character encoding of the repository files.
	 -g --language LANGUAGE       Value for the Content-Language header and $LANG
				      environment variable.
	 -d --with-diff 	      Include the diff in the message.
	 -a --attach-diff	      Attach the diff to the message.
	 -w --diff-switches SWITCHES  Switches to pass to C<svnlook diff>.
	 -R --reply-to ADDRESS	      Address for use in the Reply-To header.
	    --add-header NAME=VALUE   Add an extra header to the email.
	 -P --subject-prefix PREFIX   String to prepend to the subject.
	 -C --subject-cx	      Include the context of the commit in the
				      subject.
	 -X --strip-cx-regex	      Regex to remove part of the CX file name from
				      the subject.
	 -O --no-first-line	      Do not include the first line of the log
				      message in the subject.
	 -i --max-sub-length LENGTH   Maximum size of the subject line.
	 -e --max-diff-length LENGTH  Maximum size of the diff output.
	 -H --handler HANDLER	      The notification handler, such as "HTML".
	 -F --filter FILTER	      An output filter, such as "Markdown".
	 -A --author-url URL	      Include link to specified author URL.
	 -U --revision-url URL	      Include links to specified Revision URL.
	 -T --rt-url URL	      Include links to specified Request Tracker URL.
	 -B --bugzilla-url URL	      Include links to specified Bugzilla URL.
	 -J --jira-url URL	      Include links to specified JIRA URL.
	 -G --gnats-url URL	      Include links to specified Gnats URL.
	    --ticket-map REGEX=URL    Regex and URL for custom ticket identifiers.
	    --header HEADER	      Text header to display before body.
	    --footer FOOTER	      Text footer to display at end of body.
	 -V --verbose		      Incremental verbose mode.
	 -h --help		      Print this usage statement and exit.
	 -m --man		      Print the complete documentation and exit.
	 -v --version		      Print the version number and exit.

       More options may be supported by the subclass of SVN::Notify specified by the "--handler" option or by filters specified by the "--filter"
       option. Consult the documentation of the relevant modules for details.

See Also
       See SVN::Notify for the complete documentation. If you're having issues with character encodings, see especially the Character Encoding
       Support section.

Author
       David E. Wheeler <david@kineticode.com>

Copyright and License
       Copyright (c) 2004-2009 Kineticode, Inc. Some Rights Reserved.

       This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

perl v5.10.1							    2011-03-15							     SVNNOTIFY(1p)
All times are GMT -4. The time now is 07:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy