如何在Geektool中运行Ruby脚本? [英] How to run Ruby scripts in Geektool?
问题描述
我想在Geektool中运行一个Ruby脚本,该脚本每3小时刷新一次(因此我将刷新速率设置为10,800秒),并且Geektool中的shell命令中包含以下代码:
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
但是它仍然不起作用.我不希望它使用我的/usr/bin/ruby
安装(默认情况下为1.8.7),我希望它使用1.9.3.这样做:/usr/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.
在Terminal中,如果我运行这些命令中的任何一个它们都可以工作(由于依赖关系,后者除外)并且我的脚本可以正常运行,但是Geektool甚至无法执行它.我尝试过在文件名周围使用双引号,也没有双引号,即使单引号也不起作用.
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.
任何帮助将不胜感激.
推荐答案
我还需要一个rvm
gemset.我创建了一个外壳文件:
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
使用该shell文件(恰好位于我~
的目录中)作为shell命令,可以正常工作.
With that shell file (which happens to reside in a directory off my ~
) as the shell command it works fine.
没有每个命令的完整路径,则不起作用. GeekTool无法运行您的.bash_profile
AFAICT.同样不确定是否使用不带rvm Ruby的rvm Ruby是否可以满足您的要求.
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.
这篇关于如何在Geektool中运行Ruby脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!