在我的控制器中,我试图执行一个 ruby 脚本:
def mymethod
variable = `ruby /home/user/Test.rb`
exec variable
raise "Failed: #{variable}" unless variable.blank?
end
Test.rb 脚本存在于上述路径中,即使这样我也会收到错误消息:
Errno::ENOENT (No such file or directory - )
Test.rb 内容:
require 'rubygems'
require 'net/smtp'
require 'pp'
require 'mysql'
require 'yaml'
message = "MESSAGE_END
G Name <MyEmailAddress>
To: G Name <MyEmailAddress>
Subject: SMTP e-mail test
This is a test mail"
Net::SMTP.start('webserver') do |smtp|
smtp.send_message message, 'EmailAddress', 'EmailAddress'
end
当我手动运行此脚本时。它按预期发送邮件。