How to run Ruby scripts in Geektool?

被刻印的时光 ゝ 提交于 2019-12-11 23:21:29

问题


I want to run a Ruby script in Geektool that refreshes every 3 hours (so I set the refresh rate to 10,800 seconds) and the shell command in Geektool has this code in it:

ruby "/file.rb"

The file is located at root for convenience. Problem is, it won't run. I tried different commands, such as:

/Users/userhere/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /file.rb

But it still doesn't work. I don't want it to use my /usr/bin/ruby installation (which, by default, is 1.8.7), I want it to use 1.9.3. So doing: /usr/bin/ruby "/file.rb" won't work for me.

In Terminal, if I run any of those commands they all work (except for the latter, because of dependencies) and my script works fine, but Geektool fails to even execute it. I tried with and without double quotes around the file name, even single quotes don't work.

Any help would be greatly appreciated.


回答1:


I needed an rvm gemset as well; I created a shell file:

/Users/Dave/.rvm/bin/rvm use 1.9.3-p0 > /dev/null
/Users/Dave/.rvm/rubies/ruby-1.9.3-p0/bin/ruby ~/foo.rb

With that shell file (which happens to reside in a directory off my ~) as the shell command it works fine.

Without the full paths to each command it doesn't work. GeekTool doesn't run your .bash_profile AFAICT. Also not sure that running an rvm Ruby w/o using it would do what you want anyway.



来源:https://stackoverflow.com/questions/8528536/how-to-run-ruby-scripts-in-geektool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!