Sunday, November 27, 2011

launchd: This program is not meant to be run directly.


Periodically I export my bookmarks into my ~/Sites/bm folder. One problem I had was that neither Firefox nor Google Chrome set permissions to 644 on the files they export. This means Apache can't read them from my "userdir". In order to be able to browse them I need to periodically turn on the "r" bits on the files in that directory.

On Linux, and on OSX in the past I used cron to do it, like this:

crontab -e

# This is ~/mcook/.crontab
#
# Format used in /etc/crontab:
#
# minute        hour    mday    month   wday    who     command
#
# Format used in ~/.crontab:
#
# minute        hour    mday    month   wday    command
#
# NOTE: Use TAB to separate entries!
#
0       *       *       *       *       cd ~/Sites/bm;chmod +r *;logger mcook Running chmod +r star in ~/Sites/bm chmod at 0 minutes of the hour
15      *       *       *       *       cd ~/Sites/bm;chmod +r *;logger mcook Running chmod +r star in ~/Sites/bm chmod at 15 minutes of the hour
30      *       *       *       *       cd ~/Sites/bm;chmod +r *;logger mcook Running chmod +r star in ~/Sites/bm chmod at 30 minutes of the hour
45      *       *       *       *       cd ~/Sites/bm;chmod +r *;logger mcook Running chmod +r star in ~/Sites/bm chmod at 45 minutes of the hour 

OSX Lion still seems to have cron turned on by default but Apple would prefer me to use launchd, so I decided to take the plunge and learn about it.

In the process, I was trying to run a shell script using launchd and I coded myself up a .plist following an example that used the <ProgramArguments> array.

[My example would go here but I lost it].

However, when I tried to load it I would get:

launchd: This program is not meant to be run directly.

After a lot of web-searching I found a suggestion that in some cases you have to use <Program>.

I changed my .plist accordingly, and now it works.

So, if you get "launchctl: this program is not meant to be run directly." you might try putting the shell script's name in the <Program> key, rather than using the first element of the <ProgramArguments> array in your plist.


2011-11-27


0 comments: