[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Finding out in-memory size of an email

Petr Janda

12/17/2008 7:33:00 AM

Hi all,
I have a script that executes sendmail binary like this

exec '/usr/sbin/sendmail'

This opens op the sendmail STDIN that waits for the email to be typed or
inputed via other means(postfix). Is it at all possible to actually
find out the size of the email(in bytes) thats going into sendmail?

Petr
--
Posted via http://www.ruby-....

1 Answer

Brian Candler

12/17/2008 11:10:00 AM

0

Petr Janda wrote:
> I have a script that executes sendmail binary like this
>
> exec '/usr/sbin/sendmail'
>
> This opens op the sendmail STDIN that waits for the email to be typed or
> inputed via other means(postfix). Is it at all possible to actually
> find out the size of the email(in bytes) thats going into sendmail?

Not sure how this relates to Ruby.

If your ruby script is using 'exec' like that, then it is *replacing*
the entire Ruby interpreter with sendmail. At that point, sendmail is
running, accepting data on stdin, and Ruby has terminated. So sendmail
knows the size of the E-mail, but there is no-one to tell.

Perhaps what you want is to keep Ruby running while sending data to
sendmail, e.g. (untested)

count = 0
IO.popen("/usr/sbin/sendmail","w") do |sendmail|
while data = $stdin.read(4096)
sendmail << data
count += data.size
end
end
STDERR.puts "Thank you. You sent #{count} bytes."
--
Posted via http://www.ruby-....