procmail
[Top] [All Lists]

RE: Get domain and tld ?

2009-01-25 20:01:26
LuKreme Monday, January 26, 2009 1:06:

On 25-Jan-2009, at 15:58, Dallman Ross wrote:
LuKreme wrote Sunday, January 25, 2009 22:24:


I want to say "sure," but frankly I have no idea what
"the cli" is.  ("Computer Luser Interface"?)  But I'll say "sure"

Commnd line interface.  Bash, sh, tcsh, etc. It's a back 
formation to distinguish from a GUI.

Yes, but you write "GUI," not "gui."  If you had written
"CLI" I'd have figured it out.  I even noticed that you
capitalized "ARG," which I wouldn't have done, so I didn't
then think you had a sudden one-word aversion to capital letters.


# Check if FQDN was set
:0
* FQDN ?? ^^^^
{
  #not set, check for ARG, if it's not set, bailout
  FQDN = $1

  :0
  * FQDN ?? ^^^^
  {
    SWITCHRC
    HOST
  }
}

This way, if you SWTICHRC it works, and if you run it from
the cli it works...

Well, whatever, but I don't see why you want to run the "test-for-
empty" condition twice.  It seems like a needless complexity to me.

Because you set (or tried to set) FQDN to $1 in the meantime.

I understand full well why you have it there.  I am complaining
about the design of your algorithm, is all. :-)

Here's how I'd do something like that, in pseudocode:

1) If exist arg, set FQDN = arg
2) Else if FQDN empty, bail

Corollary to 1): If FQDN not empty and arg not empty, ask self
why the bleep we have an arg and how our code got dirty enough to
cause that to happen.

And we can furthermore shorten 1) to just: 

   set FQDN = arg

And, likewise, we can shorten 2) to just:

   If FQDN empty, bail

And, by gum, that's what I had originally.


Also, simply unsetting SWITCHRC will end the rcfile.  If
there are no parent rcfiles to return to, then procmail
will end and the mail will be delivered to $DEFAULT.  That
probably isn't what you want to achieve with the above sample
code.

But if you are running this from the command-line, SWITCHRC
will not end processing, so you still need HOST.

Nope.

Run this from the CLI: ;-p

  ################ start rcfile ################

  SWITCHRC
  LOG = "Kilroy was here.
  "
  ################# end rcfile #################

Suggested command line:

 % procmail -m DEFAULT=/dev/null rcfile < /dev/null

Then email me with a word on how you'll send your check.  :-)

(Oh, and if you didn't set DEFAULT=/dev/null or unset HOST or
set it to something invalid, you'll also now have a null-length
message in your $DEFAULT folder.)


Your understanding of how SWITCHRC works is flawed.  The
current file will not continue if SWITCHRC is simply unset.
See "man procmailrc".

I did: 

   Names an rcfile (relative to the current directory) to which
   processing will be switched.  If the named rcfile doesn't
   exist or is not a normal file or /dev/null then an error
   will be logged ***and processing will continue in the current
   rcfile.***

You read it, but you didn't grok it.  The case you have presented
does not meet the criteria described in the first clause of the 
second quoted sentence: (a) there is *no* named rcfile; and
thus, by definition, (b) there likewise is nothing to discern as
either a normal file or /dev/null.  There is no "ARG," as you put 
it, to the SWITCHRC statement in your syntax.

"No named rcfile" is no the same as "a named rcfile that doesn't exist."

Dallman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>