Procmail to ruby

Hello,

I want to write a Procmail recipe that pipes a message to a
Ruby script as ARGV argument.
I wrote this recipe but it doesn’t work.

:0

  • ^TO_*
    | ruby main.rb

How can I pass a message as argument to the script?

I wrote this recipe but it doesn’t work.

:0

  • ^TO_*
    | ruby main.rb

How can I pass a message as argument to the script?

You don’t pass the message as an argument, you pass it on standard input

the pipe in the procmail recipe acts much like shell piping.

There are several ways to get standard input in Ruby, here’s one using
the
‘magic’ variable ARGF:

$ cat test.text
this is just a test line
$ cat test.rb
ARGF.each_line do |line|
puts line
end
$ cat test.text | ruby test.rb
this is just a test line
$

HTH,

Felix

On Mon, 5 Nov 2007 15:05:36 +0100
Mislav K. [email protected] wrote:

How can I pass a message as argument to the script?
e.g.

:0 fw

  • ^X-MS-Has-Attach: yes
    | ${HOME}/bin/fixup_b0rken_tnef.rb

On Mon, 05 Nov 2007 14:50:30 -0800
barjunk [email protected] wrote:

:0

The above implies a properly formated bang line, correct?

As quoted yes, but the following works as well, assuming ruby in on
the PATH known to procmail.

:0 fw

  • ^X-MS-Has-Attach: yes
    | ruby ${HOME}/bin/fixup_b0rken_tnef.rb

-jh

On Nov 5, 8:01 am, Jonathan H. [email protected] wrote:

  • ^TO_*
    | ruby main.rb

How can I pass a message as argument to the script?

e.g.

:0 fw

  • ^X-MS-Has-Attach: yes
    | ${HOME}/bin/fixup_b0rken_tnef.rb

The above implies a properly formated bang line, correct?

Mike B.