Forum: Ruby Send email when a error occurs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
874e511e8d97f277a35b562c7c3b9a12?d=identicon&s=25 Ivan Vieira (darth_ivan)
on 2007-03-30 20:52
I have a script in ruby that build a software for me once per day and
when the code is wrong and a error, I don't if the error has ocurred and
I don't know what happened.

I wanna know how I can saw the error, I want that this script tell me
what happenend by email.

Thanks,

Ivan
8f6f95c4bd64d5f10dfddfdcd03c19d6?d=identicon&s=25 Rick Denatale (rdenatale)
on 2007-03-31 01:15
(Received via mailing list)
On 3/30/07, Ivan Vieira <ivan.vieira@atan.com.br> wrote:
> I have a script in ruby that build a software for me once per day and
> when the code is wrong and a error, I don't if the error has ocurred and
> I don't know what happened.
>
> I wanna know how I can saw the error, I want that this script tell me
> what happenend by email.

Search for the docs on Net::SMTP in the ruby standard library.


--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (Guest)
on 2007-03-31 10:42
(Received via mailing list)
On Sat, Mar 31, 2007 at 03:52:29AM +0900, Ivan Vieira wrote:
> I have a script in ruby that build a software for me once per day and
> when the code is wrong and a error, I don't if the error has ocurred and
> I don't know what happened.
>
> I wanna know how I can saw the error, I want that this script tell me
> what happenend by email.

How are you running it daily? If running from cron, then cron should
capture
your script's output and mail it to the cron user's uid.

Otherwise you could do something like
  IO.popen("sendmail you@yourdomain.com","w") do |io|
    io << EOM
From: system@yourhost
To: you@yourdomain.com

Something nasty has happened!
EOM
  end

YMMV (you didn't say if this was Windows or Linux/Unix or something
else)

B.
This topic is locked and can not be replied to.