2013-02-11 54 views
1

在我的控制,我試圖執行一個Ruby腳本:變量Errno :: ENOENT(沒有這樣的文件或目錄 - )

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 

當我手動運行該腳本。它按預期發送郵件。

+0

什麼樣的輸出呢'Test.rb'產生? – Casper 2013-02-11 15:09:38

+0

你想打開該文件還是什麼? – Vinay 2013-02-11 15:10:44

+0

@Casper:更新了我的問題 – Supersonic 2013-02-11 15:15:46

回答

1

你必須

require 'open-uri' 

所以,

require '/home/user/Test.rb' 
require 'open-uri' # sometimes without this line, we get the exact error message in ruby on rails.. 

(或)

嘗試重新啓動服務器,有時它的修復它..

+0

需要'/home/user/Test.rb'的工作感謝 – Supersonic 2013-02-11 15:24:44

+0

有人被放下這個答案downvote ....天才 – Vinay 2013-02-11 15:25:15

相關問題