Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Using /usr/sbin/sendmail in Ruby Script

Reply
Thread Tools

Using /usr/sbin/sendmail in Ruby Script

 
 
Dan Sinclair
Guest
Posts: n/a
 
      11-19-2009
Hi Guys,

I'm very new to Ruby, so please bare with me!

I'm trying to make a ruby script that runs a command/executable. The
command/executable is native to Mac OS X 10.5 and 10.6. It's the
sendmail command (found in /usr/sbin/sendmail). The script I have so far
is this:

###################################

when "email"
begin
job_media = ENV['job_media']
job_reason = ENV['JOB_REASON']
e_address = get_node_value('post-action-e-address')
eeemail(job_media, job_reason, e_address)
end

###################################

def eeemail(job_media, job_reason, e_address)

RECIPIENT = http://www.velocityreviews.com/forums/(E-Mail Removed)
MEDIA = blah
REASON = job_reason
SUBJECT = "Engine Admin - Job #{REASON}"

exec("/usr/sbin/./sendmail #{RECIPIENT} << EOF
From: "Episode Engine" <(E-Mail Removed)>
Subject: "#{SUBJECT}"

"Job #{MEDIA} has #{REASON}"
EOF")

end

###################################

This script will run when a piece of software my company sell, finishes
a task. The main thing I'm not getting to work is the:

exec("/usr/sbin/./sendmail #{RECIPIENT} << EOF
From: "Episode Engine" <(E-Mail Removed)>
Subject: "#{SUBJECT}"

"Job #{MEDIA} has #{REASON}"
EOF")

Any ideas will be greatly appreciated.

Regards,

Dan
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Aldric Giacomoni
Guest
Posts: n/a
 
      11-19-2009
Dan Sinclair wrote:
> Hi Guys,
>
> I'm very new to Ruby, so please bare with me!
>
> I'm trying to make a ruby script that runs a command/executable. The
> command/executable is native to Mac OS X 10.5 and 10.6. It's the
> sendmail command (found in /usr/sbin/sendmail).


Why not let Ruby do it all?
http://gemcutter.org/gems/mail
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Dan Sinclair
Guest
Posts: n/a
 
      11-19-2009
Aldric Giacomoni wrote:
> Dan Sinclair wrote:
>> Hi Guys,
>>
>> I'm very new to Ruby, so please bare with me!
>>
>> I'm trying to make a ruby script that runs a command/executable. The
>> command/executable is native to Mac OS X 10.5 and 10.6. It's the
>> sendmail command (found in /usr/sbin/sendmail).

>
> Why not let Ruby do it all?
> http://gemcutter.org/gems/mail


...because not all of my customers will have this installed, and as i
recall from looking at that before, you need to have an SMTP server set
up too...whereas if i use the sendmail command, it's already to go with
Mac OS X...

Regards,

Dan
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Dan Sinclair
Guest
Posts: n/a
 
      11-19-2009
Dan Sinclair wrote:
> Aldric Giacomoni wrote:
>> Dan Sinclair wrote:
>>> Hi Guys,
>>>
>>> I'm very new to Ruby, so please bare with me!
>>>
>>> I'm trying to make a ruby script that runs a command/executable. The
>>> command/executable is native to Mac OS X 10.5 and 10.6. It's the
>>> sendmail command (found in /usr/sbin/sendmail).

>>
>> Why not let Ruby do it all?
>> http://gemcutter.org/gems/mail

>
> ...because not all of my customers will have this installed, and as i
> recall from looking at that before, you need to have an SMTP server set
> up too...whereas if i use the sendmail command, it's already to go with
> Mac OS X...
>
> Regards,
>
> Dan


sorry...my bad...looks like i ddin't read up on that specific ruby mail
add on...it would still be easier however for my customers to not need
to install something else.

Regards,

Dan
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Dan Sinclair
Guest
Posts: n/a
 
      11-19-2009
Dan Sinclair wrote:
> Dan Sinclair wrote:
>> Aldric Giacomoni wrote:
>>> Dan Sinclair wrote:
>>>> Hi Guys,
>>>>
>>>> I'm very new to Ruby, so please bare with me!
>>>>
>>>> I'm trying to make a ruby script that runs a command/executable. The
>>>> command/executable is native to Mac OS X 10.5 and 10.6. It's the
>>>> sendmail command (found in /usr/sbin/sendmail).
>>>
>>> Why not let Ruby do it all?
>>> http://gemcutter.org/gems/mail

>>
>> ...because not all of my customers will have this installed, and as i
>> recall from looking at that before, you need to have an SMTP server set
>> up too...whereas if i use the sendmail command, it's already to go with
>> Mac OS X...
>>
>> Regards,
>>
>> Dan

>
> sorry...my bad...looks like i ddin't read up on that specific ruby mail
> add on...it would still be easier however for my customers to not need
> to install something else.
>
> Regards,
>
> Dan


...no no my bad on my bad....lol. It DOES need an SMTP server
configured.

Regards,

Dan

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Aldric Giacomoni
Guest
Posts: n/a
 
      11-19-2009
Dan Sinclair wrote:
>
> sorry...my bad...looks like i ddin't read up on that specific ruby mail
> add on...it would still be easier however for my customers to not need
> to install something else.


you could also make your script into a stand-alone executable like such:
http://www.erikveen.dds.nl/rubyscript2exe/

But, anyway - how is your code failing? have you tried using 'system'
instead of 'exec' ?
http://blog.jayfields.com/2006/06/ru...xec-and-x.html
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(How) Can you run another ruby script, from a ruby script? 3lionz Wexler Ruby 2 08-24-2010 04:27 AM
how to test a ruby script from another ruby script? Saravanan Sundaramoorthy Ruby 1 07-19-2010 12:06 PM
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
Pass variables to arbitrary ruby script: ruby script.rb Mario Gr Ruby 3 07-04-2009 06:00 AM
"ruby script.rb" versus "xterm -e ruby script.rb" Sy Ruby 0 04-16-2005 12:08 AM



Advertisments