TextMate에 내장 된 Ruby 스크립트가 있으며 TextMate에서 성공적으로 실행할 수 있습니다. 또한이 스크립트를 터미널에서 바로 실행할 수 있습니다.Ruby, Mac, Geektool 질문, 파일 액세스 권한?
스크립트는 코드의 덩어리를 가지고 :
스크립트가 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'
, 그것은 puts 'File is opened'
과거 얻을 수 없다. 그것은 심지어 puts 'The End'
을 치지 않습니다. 전혀 오류가 없습니다.
이 스크립트는 Mac의 /System
폴더 아래에 있지만, "everyone"이 "& 쓰기"액세스 권한을 가질 수 있도록 파일 사용 권한을 변경했습니다. EDIT 방금 내 사용자 홈 폴더 아래에있는 폴더에 파일을 복사했지만 여전히 GeekTool에는 문제가 있지만 TextMate에는 문제가 있거나 터미널을 통해 직접 문제가 없습니다.
최종 편집
2 편집
내가 GeekTool 아마 파일 경로에 문제가있을 수 있습니다 생각합니다.
예를 들어 지금 당장 인터넷에서 XML 파일을 읽도록 프로그램을 변경했지만 프로그램은 growlnotify의 아이콘에 사용중인 일부 이미지가 있습니다. TextMate를 실행할 때 이러한 아이콘이 완벽하게 표시됩니다. GeekTool을 사용하여 실행할 때 ... 아니요. 사용자 정의 아이콘이 전혀 없습니다.
마치 GeekTool이 파일 경로를 올바르게 처리하지 못하는 것 같습니다. puts __FILE__.to_s
할 때 내 .rb 파일에 올바른 파일 경로를 제공합니다.
** 끝 2 번째 편집 ** 어떻게해야합니까?
당신이 실행하려는 geektool에서 실제 쉘 명령은 무엇을 사용
으로 검색 할 수 있습니까? – wesgarrison
ruby /path/to/my/file.rb 정확한 명령을 터미널에 입력하면 작동합니다. –