Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Running Unix commands directly in launchd--guidelines, tips?

I've been gradually migrating my cron entries over to launchd and having no trouble for the most part, but in cron I have some commands like this:

scp /Volumes/data/basketball/girls/data/*.txt loginid@pubsys.example.com:remote/cgi-bin/basketball/girls/data/

No problem in cron, but launchd stumbles on these kinds of things frequently. I understand that you can't necessarily have commands in there like that, but I've gotten some to run. I've discovered that rewriting some command like this to have quotes around each parameter works:

scp "/Volumes/data/basketball/girls/data/*.txt" "loginid@pubsys.example.com:remote/cgi-bin/basketball/girls/data/"

In this particular case, FWIW, that doesn't work. It still errors out, but it has worked for other commands. I'm still tinkering with it, but I'm wondering what the rules are when it comes to running commands directly in launchd like that. Are you supposed to do it this way? I'm hoping I don't have to create a separate shell script for each of these. It was really convenient in cron to be able to run commands directly in the utility itself.

Mac OS X (10.5.6)

Posted on Feb 2, 2009 3:47 PM

Reply
Question marked as Best reply

Posted on Feb 2, 2009 3:54 PM

Your cron job will run as you; launchd does not guarantee a login shell environment. I'm guessing the errors you're encountering pertain to a lack of credentials on the remote server.
6 replies

Feb 2, 2009 5:05 PM in response to Linc Davis

Linc Davis, that pretty much tells me I either have to put these in a separate shell script to run through launchd or save myself the hassle and continue using cron for some jobs. Oh well, I'm not opposed to using both launchd and cron, but it would be nice if launchd were able to handle running commands directly like that and everything could be contained in one place.

Message was edited by: Rick Anderson

Running Unix commands directly in launchd--guidelines, tips?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.