6

Upgraded to Mavericks and now launchd / Lingon is unable to launch Ruby scripts. I have the files set to be executable (using chmod +x), and have the first lines set to

#!/usr/bin/ruby

However, I keep getting the following error in Console:

com.apple.launchd.peruser.501[169] (craig.logging[754]): Exited with code: 1

That is a permissions error, but I have no idea what permissions to fix or change. The script runs fine in terminal with ruby.

This is driving me nuts.

Update: the Ruby scripts that are causing the problem write their output to another file, for example, in my Dropbox. But I'm running the launchd files as myself who has admin privileges to write to those files. No idea what's going wrong...]

Update 2: Have started using Applescript to launch the Terminal and run my scripts, but this is pretty clumsy and inelegant. Anyone else have any insight to why launchd won't run scripts that write their output to files? Or is anyone having success with scripts that do?

Update 3: The failures were being triggered because of encoding issues. I had to specifically set file.open(path/to/file, encoding: 'UTF-8') for the scripts to work.

Thanks everyone.

4

2 回答 2

1

我仍然不完全确定为什么,但是由于编码问题而触发了权限错误。我必须专门这样做:

File.open(path/to/file, encoding: 'UTF-8')     

让脚本正常工作。

感谢大家的帮助。

于 2014-01-06T21:58:57.580 回答
1

我在 Mavericks 机器上遇到了同样的问题,我设置了几个 Ruby 脚本以不同的时间间隔运行。我发现虽然这台升级了操作系统的机器出现故障,但我与 Mavericks 一起提供的新 MacBook Pro 可以launchd很好地安排相同的脚本。我最终擦除了机器并从头开始重新安装了 Mavericks(以及其他所有东西),然后安排脚本开始工作。

我知道,这不是最微妙的答案,而是为我工作™。

于 2013-12-20T15:43:18.563 回答