我有一個我在TextMate中構建的Ruby腳本,並且可以在TextMate中成功運行。 我也可以直接從終端成功運行這個腳本。Ruby,Mac,Geektool問題,文件訪問權限?
該腳本的代碼,這個塊在裏面:
# Get the XML file
puts 'Opening the file'
open("messages.xml", "r") do |f|
puts 'File is opened'
theXML = Hpricot::XML(f)
puts 'Trying to get the message_entity'
message_entity = GetMessage(theXML)
# Build the system command
puts 'Getting the author and the message'
theAuthor = message_entity.search(:author).text
theMessage = message_entity.search(:messagetext).text
# Get the correct image for this author
theAuthorImage = ''
case theAuthor
when 'James' : theAuthorImage = 'images/me32.png'
when 'Zuzu' : theAuthorImage = 'images/Zuzu32.png'
end
puts "/usr/local/bin/growlnotify '" + theAuthor + " says' -m '" + theMessage + "' -n 'Laurens Notes' --image '" + theAuthorImage + "'"
#system("/usr/local/bin/growlnotify '" + theAuthor + " says' -m '" + theMessage + "' -n 'Laurens Notes' --image '" + theAuthorImage + "'")
end
puts 'The End'
當腳本由GeekTool運行時,它永遠不會越過puts 'File is opened'
。它甚至沒有打到puts 'The End'
。它根本沒有錯誤。
該腳本位於我Mac上/System
文件夾下的文件夾下,但我已更改文件權限以允許「everyone」具有「讀取&寫入」權限。 編輯 我只是將文件複製到我的用戶主文件夾下的文件夾,它仍然存在GeekTool中的問題,但不是在TextMate中,或直接通過終端。
編輯完
第二編輯
我認爲GeekTool可能會出現問題與路徑也許文件。
例如,我改變了計劃,而只是直接從互聯網上讀取XML文件,現在它確實是不錯,但也有該程序的growlnotify使用的圖標一些圖像。通過TextMate運行時,這些圖標完美顯示。當使用GeekTool運行時...不行。根本沒有自定義圖標。
就好像GeekTool無法正確處理文件路徑一樣。 當我做puts __FILE__.to_s
它雖然給我正確的文件路徑到我的.rb文件。
** end第二次編輯** 我該怎麼辦?
是什麼在geektool實際shell命令,你試圖運行? – wesgarrison 2009-12-18 05:15:46
ruby /path/to/my/file.rb 如果我在終端鍵入確切的命令它的作品。 – 2009-12-18 16:08:15