"procmail" <procmail(_at_)internet-lab(_dot_)com> writes:
Given the following recipe, if no value is found - which sometimes will
be the case - procmail does not continue reading the recipe and never
gets to the end where the program is triggered using the input values.
What syntax is necessary in order for procmail to continue reading
and processing even though it encounters no value for one or more
fields?
Yes, because that's what the nested block means: if the condition fails,
nothing inside the nested block should be run. If that's not what you
want then you shouldn't put everything inside the nested block of the
previous condition, but rather only the variable assignment from MATCH.
So, you first task is to figure out what parts really are required.
I'll assume that the only parts that are optional in what follows are
the HOST, IPADDRESS, and CNAME values.
Speaking of which, you can't use the HOST variable for this, because
it's magical in procmailrcs. Please read the procmailrc(5) manpage for
the details.
PATH=$HOME/bin:/usr/bin:/usr/ucb:/bin:/usr/local/bin:.
Don't change PATH unless you have a reason to do so. I have yet to see
an rcfile that needed '.' in its path.
:0
* ^Subject: *\/ref[^ ]+
{
REF=$MATCH
:0B
* ^Enter the domain name:\/.+[a-z0-9]
{
NEWDOM=$MATCH
:0B
* ^First and last name of contact:\/.+[a-z0-9]
{
CONTACT=$MATCH
:0B
* ^E-mail address of contact:\/.+[a-z0-9]
{
EMAIL=$MATCH
:0B
* ^Phone number of contact:\/.+[a-z0-9]
{
PHONE=$MATCH
:0B
* ^Name of organization:\/.+[a-z0-9]
{
ORG=$MATCH
HOSTNAME
:0B
* ^Optional 1st hostname [^:]*:\/.+[a-z0-9]
{
HOSTNAME=$MATCH
}
IPADDRESS
:0B
* ^IP address if provided:\/.+[a-z0-9]
{
IPADDRESS=$MATCH
}
CNAME
:0B
* ^CNAME if it applies [^:]*:\/.+[a-z0-9]
{
CNAME=$MATCH
}
:0 i
| /usr/local/adm/build_domain "$NEWDOM" \
"$CONTACT" "$EMAIL" "$PHONE" "$ORG" \
"$HOSTNAME" "$IPADDRESS" "$CNAME"
}
}
}
}
}
}
NOTES:
1) for the optional variables, you should make sure they're unset or
empty, just in case something earlier in the rcfile set them for some
unrelated reason. In the above, I unset them.
2) Did you forget to pass REF to the script?
3) All the variable except REF may contain whitespace, and the HOSTNAME,
IPADDRESS, and CNAME variables may (now) be empty, so they must be
quoted on the command line to keep them from being split into multiple
arguments or from---for empty variables---disappearing completely.
Note that this means that they may have leading whitespace on them now.
You can fix that by altering the match conditions from:
* ^Enter the domain name:\/.+[a-z0-9]
to
* ^Enter the domain name:[ ]*\/[^ ].*[a-z0-9]
4) square brackets are special characters for regexps, so inside
conditions you either need to escape them with backslashes or other
match their text. In the above, to keep from running of the right hand
side of the screen, I matched "[default www]" and "[default www.ncgov.com]"
with a simple "[^:]*:" which will match everything up to the next colon.
Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail