I have a Ruby script that I built in TextMate and can successfully run in TextMate. I can also successfully run this script straight from the terminal.
The script has this chunk of code in it:
# 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'
When the script is run by GeekTool, it never gets past puts 'File is opened'
. It doesn't even hit puts 'The End'
. It gives no error at all.
The script is under a folder under the /System
folder on my Mac, but I have changed the file permissions to allow "everyone" to have "read & write" access.
EDIT
I just copied the files to a folder directly under my user home folder, and it still has the issue in GeekTool but not in TextMate or straight through the Terminal.
END EDIT
2nd Edit
I think GeekTool may have an issue with paths to files maybe.
For example, I changed the program to just read the XML file straight from the Internet for now and it does that just fine, but there are some images that the program is using for the icons in growlnotify. When run through TextMate, these icons display perfectly. When run using GeekTool...nope. No custom icon at all.
It's as if GeekTool just can't handle the file paths correctly.
When I do puts __FILE__.to_s
it gives me the correct filepath to my .rb file though.
** end 2nd edit** What should I do?
Geektool runs all the commands from / so relative path names will not work when trying to run growlnotify.
You will need to pass the absolute paths of the images to growlnotify.
The current path can be retrieved with
So you would use