Skip navigation
This discussion is archived

Ruby scripts & launchd

2403 Views 6 Replies Latest reply: Nov 26, 2007 10:57 AM by jarik RSS
avicenna Calculating status...
Currently Being Moderated
Nov 26, 2007 5:12 AM
I have writting a ruby script for use by launchd. The script runs fine on it on without launchd and been tested several times on several items. However, when loaded by launchd it gives an error and exits. Here is the launchd plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.avicenna.webloc2url</string>
<key>LowPriorityIO</key>
<true/>
<key>Program</key>
<string>/Users/avicenna/Library/Scripts/webloc2url.rb</string>
<key>ProgramArguments</key>
<array>
<string>webloc2url.rb</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/avicenna/Downloads/Bookmarks</string>
</array>
</dict>
</plist>

and here is the syslog error:

Nov 26 15:35:13 avicenna com. avicenna.webloc2url[17236]: nil
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: /Users/avicenna/Library/Scripts/webloc2url.rb:10
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: : private method `sub!' called for nil:NilClass (NoMethodError)
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: from /Users/avicenna/Library/Scripts/webloc2url.rb:4:in `each'
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: from /Users/avicenna/Library/Scripts/webloc2url.rb:4
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: nil
Nov 26 15:35:38 avicenna com.apple.launchd[132] (com. avicenna.webloc2url[17243]): Exited with exit code: 1

regarding the error:
private method `sub!' called for nil:NilClass (NoMethodError)

the stand alone script never complains about such an error, actually it does the substitution and prints what is expected. In fact, the script does the job well. So, this makes me think that there might be some limitation on the execution of ruby scripts by launchd? Or maybe the parameters I've put in the plist file are not correct or missing something?
Any kind of help or hint would be appreciated.

Thanks.
Powerbook 12", Mac OS X (10.5.1)
  • jarik Level 4 Level 4 (1,005 points)
    Currently Being Moderated
    Nov 26, 2007 6:44 AM (in response to avicenna)
    I think it would be helpful to look at (some of) the ruby script being run.
    MacBook Pro, Powerbook G4, Mac OS X (10.5.1)
  • jarik Level 4 Level 4 (1,005 points)
    Currently Being Moderated
    Nov 26, 2007 8:43 AM (in response to avicenna)
    My ruby is a bit rusty, but have you tried

    p y
    p y.methods


    where you have the puts call to debug?

    The error is saying the method sub! is not defined for the object...
    MacBook Pro, Powerbook G4, Mac OS X (10.5.1)
  • jarik Level 4 Level 4 (1,005 points)
    Currently Being Moderated
    Nov 26, 2007 10:57 AM (in response to avicenna)
    No bother, you're welcome and I'm glad it works now.
    MacBook Pro, Powerbook G4, Mac OS X (10.5.1)

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.