That's an interesting find, the fact that you can post notifications across sessions - I wasn't aware of that. And it turns out that this was the solution.
PHP does run as a separate user, but it doesn't seem to matter. Thanks, Daniel, and everyone, for your help! Rainer On Aug 23, 2011, at 1:19, Daniel Acosta wrote: > On Aug 23, 2011, at 12:15 AM, Jens Alfke wrote: > >> >> On Aug 22, 2011, at 10:45 PM, Rainer Standke wrote: >> >>> I have a command line tool that uses foundation. When I run that tool from >>> the command line it does what I need it to do. This includes sending an >>> NSNotification to a Cocoa application via the >>> NSDistributedNotificationCenter. >>> >>> When I call the same command line tool from a php page served by Apache on >>> the same machine, the notification is never sent. > > I'm new to Cocoa and I may be wrong here but this got me curious. > >> >> Apache isn’t running in the same login context as your app. In fact it’s an >> entirely separate user account. Distributed notifications don’t go between >> login sessions. > > That last bit gave me the clue and found the solution in the documentation > for NSDistributedNotificationCenter. > > I just made a test using -postNotificationName:object:userInfo:options: > passing under options NSNotificationPostToAllSessions and it worked like a > charm, though I don't know if this is considered best practice. > > (http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDistributedNotificationCenter_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSNotificationPostToAllSessions) > >> >> I can’t think of any straightforward solution. Probably the best approach is >> to have your Cocoa app listen on an IP port and then the tool can send a >> message to that port. You’d have to either hardcode the port number or find >> a way to communicate the number to the tool, and the app would need to make >> sure it binds only to the loopback interface to avoid the possibility of >> getting pinged by another machine. >> >> —Jens_______________________________________________ > > You may also want to double-check permissions on your command line tool, to > make sure Apache (I believe by default it runs under user _www) can actually > read and execute it. > > Daniel > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com