procmail
[Top] [All Lists]

Re: How to run script through procmail

1996-09-02 04:43:41
-----BEGIN PGP SIGNED MESSAGE-----

On Fri, 30 Aug 1996, Pankaj Saxena wrote:

      :0
      * ^Subject:.*comments2
      {
              :0 c
              >> tfile
      
              :0
              | /homes/home1/pankaj/sc 
      }

I think you want something like this:

:0: comments.lock # Protect the temporary files from being overwritten
* ^Subject:.*comments2
{
    :0c # We already have a lockfile, so there's only one :
    | cat > tfile
# You only seem to want the last message, so there is only one >
# (Also note the `| cat'

    :0
    | /home/home1/pankaj/sc
# BTW: is this the right path? Your logfile says `sc: not found'
# also check the executable flag.
}

The script ("sc") is as follows:

      grep 'aaname:' tfile > temp1
      awk '{print $2}' temp1 > temp2
      cat tfile | w.pl `cat temp2`

Some notes on style: you don't need the grep, awk can do what you want. 
In the last line, you can leave out the cat tfile, as procmail already 
puts the mail on stdin.

awk '/aaname:/ {print $2}' tfile >temp2 # This replaces lines one and two
w.pl `cat temp2`

You could even do everything in perl.

#!/usr/bin/perl
@infile = <STDIN>; # Read in the file
$_ = (grep (/aaname:/, @infile) )[0]; # Find the line with aaname: on it
$aaname = (split)[1] ; # extract the second word.
# Now comes your script
# replace $ARGV[0] by $aaname and <STDIN> by @infile

- --
Guy Geens <guy(_dot_)geens(_at_)elis(_dot_)rug(_dot_)ac(_dot_)be>: Ph.D. 
student at ELIS -- TFCG / IMEC 
Home Page: http://www.elis.rug.ac.be/ELISgroups/tfcg/staff/gg.html 
finger ggeens(_at_)elis(_dot_)rug(_dot_)ac(_dot_)be for PGP public keys (or use 
keyserver) 

Twenty fallen angels heading for salvation,
Heading for the sanction, will soil the sky.
Gain a new dimension. Take a new direction.
Whirlwind of emotion for now's the time.
Twenty fallen angels heading for salvation,
Heading for the sanction, have reached the sun.
Coming to attention, going through the tension,
Praying for the sanction, you're fading out.



-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv
Comment: pgp fingerprints in message headers

iQBVAwUBMirHinwHoCha5QR1AQHS0QH/asQin1ITY0ejdI+kjGr8bB8u6pL31JNQ
3aOoVNRIUSF+IfmRBc86iY9PXzpgTtiyHyQdvyvGWxuhEHV8E+RgXw==
=2U89
-----END PGP SIGNATURE-----

<Prev in Thread] Current Thread [Next in Thread>
  • Re: How to run script through procmail, Guy Geens <=