Launchd - can it run a script when users log in OR switch?

I'm hoping to find someone who knows all the gory details of launchd. Here's the why and what: I'm trying to coerce Aperture into letting two users on the same computer share the same Aperture Library, both able to import photos and see and use what the other has done. Initially it is no problem, change the permissions so everyone has read/write/execute, put the Library in a common area, and point both person's Aperture at it. The problem is that Aperture changes permissions of things inside the Library as you use it, and especially when one person imports, the other person can't see that stuff.
So I want to run a script whenever someone logs in or becomes the active user by fast user switching; the script will simply change ownership and permissions of the library and everything in it to restore full access.
After days of research and testing, I made a test launchd plist file (this is the configuration file or agent that launchd looks at and runs your script when criteria are met). It sits in /Library/LaunchAgents/, here it is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.jim.test</string>
<key>LimitLoadToSessionType</key>
<string>LoginWindow</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/testscript.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/jim/Desktop/test.err</string>
<key>StandardOutPath</key>
<string>/Users/jim/Desktop/test.out</string>
</dict>
</plist>
The actual test script is sitting in /Library/Scripts/:
#!/bin/bash
echo "org.jim.test.plist was run at `date`"
So if the plist is loaded and the script run, the date and time are written in the test.out file on my desktop. This thing runs great when a user logs in. The problem is, it doesn't run when users switch by fast user switching. In reading the documentation, it was vague about this, whether that could be done; I thought it could.
Can anyone help with a way to get the script to run when any user takes control by any means? As an added complication, which I'll worry about later, the script has to run as root because it's the only way to get the ownership and permissions changed.
Thanks,
Jim

BobHarris is the MAN. ACLs seem to have worked. I put the Aperture Library in /Users/Shared/ApertureLibrary, restored the regular permissions as best I could (me as owner, staff as group, 755), pointed each person's Aperture to the library, then proceeded with the ACL magic. First I created a group for my wife and I, called 'aperture', in the Accounts preference pane. That was to simplify the ACLs (one entry instead of 2) and so that other users (son) aren't able to muck it up.
It took one stinking Terminal command (note that 'aperture' at the beginning of the quote is the group, not the program, folder or library):
chmod -R +a "aperture allow list,addfile,search,delete,add_subdirectory,delete_child,file_inherit,directoryinherit" ApertureLibrary.aplibrary
I was unsure whether this list of permissions was necessary or sufficient, but it seems to have worked so far. Both users can access the library. I imported a different picture by each user, and the other user could then see and delete the picture imported by the other. This was not possible before.
Bob, thanks for the great idea. After a little more testing I'll post a complete how-to in the latest "how do we share Aperture" thread, and give you due credit. The bad news is all the launchd fun is over
Jim

Similar Messages

  • ID CS5 on Mac 10.5.8 can't run java scripts from User folder

    I seem to have a problem with my java scripts in ID on my Mac. I store them in my user scripts folder, but while I can run any applescripts in the folder, doubleclicking on any of the java scripts gets me exactly nothing. If I open the scripts in Extend Script Toolkit and run them from there, they will work, but I can't run them from within ID. The scripts in the Sample Script folder work. I've tried changing the script extentions, I've opened them in the toolkit and resaved them. Still no response at all when I doubleclick on them in the scripts panel. Any idea what could be wrong? I can run the same scripts from within ID on my Windows laptop, so I don't think the scripts themselves are at fault. In fact, I just moved them into the Sample scripts folder, and they run with no problem. Does the User script folder just not work?

    Not sure what a screenshot will tell you, but here you go.
    Well, I was hoping that the icon next to the scripts would be instructive.
    Apparently not, though!
    You said the same scripts work fine if you move them into the Application Scripts folder, specifically the Sample Scripts folder. I assume, then, that the sample scripts also break if moved to the User Scripts folder?
    Is your User Scripts folder (and thus your home directory) on a non-local (network) filesystem? Are the permissions on it wacky? If you Reveal In Finder it, and Get Info, do you see anything out of the ordinary?
    What if you delete it (err, move it aside) and recreate it?
    This seems pretty strange...

  • Run LabVIEW executable when user logs off

    I have a customer request to do this.
    My customer has a computer in their plant that I wrote a LabVIEW applicaiton to monitor part of their process.  This computer performs other functions in addition to my program.  Their IT department has changed their policy that mandates that anybody using this computer has to log in under their own user name and password.  Prevoulsy it was just a group  user name and password.  What this means for me is everytime a new user needs to use the PC they have to log off and log back on.  This stops my program.
    Is there a way to have a LabVIEW executable keep running when different users log off and log on?
    Thanks
    Dan

    Sounds like you need a service. It may be a complete architecture change, but you could have an executable running as a service and a user interface executable connecting to it (e.g. via TCP/IP). The service itself can't have a UI.
    Without using a service there's no way an application can continue running when a user logs off (afaik).
    A service is started even if no user logs on.
    There's tools like srvany or similar that allow to run an executable as a service.
    Daniel
    Message Edited by dan_u on 08-18-2009 03:13 PM

  • How can I run a script when an application quit??

    Greetings all,
    I'm trying to write a script, which can be triggered automatically (to do some stuff) at the time when a given application quit. I was playing around with this test script, taking "TextEdit" as an example - it just prints a message when TextEdit exits.
    ==========================================
    +*set targetapp to "TextEdit"*+
    +*tell application "System Events" to set rr to name of the processes*+
    +*--if targetapp is not in rr then*+
    +*-- tell application targetapp to activate*+
    +*-- tell application "System Events" to set rr to name of the processes*+
    +*--end if*+
    +*set rr1 to rr*+
    +*repeat until rr1 ≠ rr and targetapp is not in rr1*+
    +*tell application "System Events" to set rr1 to name of the processes*+
    +*do shell script "sleep 1"*+
    +*end repeat*+
    beep
    +*display dialog (targetapp & " is not active anymore !") as string buttons {"OK"} default button 1 with icon 0*+
    ============================================
    Unfortunately, it seems to work if I launch TextEdit using the script itself; it doesn't work with first +*"if - end if"*+ block commented out. Does anyone know how can I achieve this? Any help or suggestion greatly appreciated. Cheers!!

    Hi santanu,
    I'm sure you can use a variation of this application of mine to do what you want. It monitors all running processes and then reports when one closes.
    --initialize previous_processes
    global previous_processes
    tell application "Finder"
    set previous_processes to get the name of every process --use "whose visible is true" to remove the background ones
    end tell
    --monitoring script
    on idle
    tell application "Finder"
    set current_processes to get the name of every process
    end tell
    set numberofprocesses to count of items in previous_processes
    set counter to 1
    repeat while counter is less than (numberofprocesses + 1)
    if current_processes does not contain item counter of previous_processes then
    display alert item counter of previous_processes & " quit!"
    end if
    set counter to counter + 1
    end repeat
    set previous_processes to current_processes
    return 1 --runs every second...can be changed
    end idle

  • I can not find firefox after it downloads. I keep getting a box that says I can't run it under this user, when I put in my user name and password it disappears

    The download appears to work ,it extracts the files then a box comes up saying I can't run it as this user( with the name of my login),. gives me the option to check my login name or check administer with a password. I have tried both, I am the only administer on the computer. Using windows vista. I have searched and some of the things like turorials etc are on my computer but I can't get the actual browser to open and there is no shortcut for firefox. Currently I am using IE since chrome kept freezing up, so does IE.

    Can you give me a screenshot of the User Accounts window in Control Panel?
    Please create a screenshot by following the guide mentioned at [[How do I create a screenshot of my problem?]].
    Once you've done this, attach the saved screenshot file to your forum post by clicking the '''Browse...''' button below the ''Post your reply'' box. You really help us to visualize the problem.

  • How can I run a script on suspend/resume?

    I'd like to run a script when a machine is about to suspend and another after it resumes. Is this possible?

    You can pipe the results of Out-Command to Out-File (or Export-Csv, etc.)  I'm not sure what kind of objects you're expecting from this script, so I'll err on the side of caution and use Format-List * in the example:
    Invoke-Command -ComputerName $servers -FilePath c:\copy.ps1 |
    Format-List -Property * |
    Out-File -FilePath $home\Desktop\copy.log

  • Is it possible to run a script when changing Yoga modes?

    I'm currently working with a vendor of Restaurant reservation software and they have a customer that would like to implement the Yoga 13 for a chain of hotels. However, due to the fact that the software requires Silverlight, it's necessary to run a script so that they can use Google Chrome and have the software keyboard pop up automatically when a text field is entered or touched. 
    I can easily run the script at login and manually unload it when done, but since Lenovo already has software (Lenovo Transition) that can trigger things when the Yoga changes modes, is there some sort of developer tool or a system-wide event that can be used to automatically load and unload the script on mode change?
    Please let me know, some Yoga sales could depend on this....and I love the Yoga.

    Well, I'm looking for a means to activate a script through the active corners, I'm not asking any questions about the script itself, so I did not think it should be posted in the AppleScript categoriy, but sure, I'll give it a go.
    (New thread in AppleScript: http://discussions.apple.com/thread.jspa?threadID=2534773&tstart=0)
    Message was edited by: Max Ocklind

  • How can i run unix script from my apex page

    how can i run unix script from my apex page and take the output of unix script as a hidden variable and display it on the report region of that page

    I had a requirement to run a Fortran program against some data that woudl be extracted from the database after the user set up their filtering criteria and made some additional input. SInce the program was to complex to conver to PL/SQL, we decided to try and invoke it from Apex. This is how I did it.
    1. I followed the steps in Tim Archer's excellent article "Oracle External Procedure to Run Host Commands" (http://www.timarcher.com/?q=node/9). If the link does nto work, google the article's title.
    Using this steps I created a function which accepts any OS command, including calling my own shell scripts, and runs them. I called my PL/SQL function "shell" instead of "USF_RUN_HOST_CMD " as Tim did in his example (step 9).
    2. In Apex,
    a. I created a button to run my shell command. (I named it P2_RUN_SHELL)
    b. I created a PL/SQL process whose source looks as follows:
    shell('/home/ackness/scripts/cr_xcf_file.sh > /tmp/cr_scfp_file.log');
    and which was conditioned on the the button P2_RUN_SHELL.
    It works like a charm.
    Note: since you can run your own scripts using this method, you can encapsulate a series of commands in a UNIX shell script and invoke that script from Apex. This allows you to be able to test or run you commands from the command line as well as Apex and makes it easier to develop/debug/enhance the scripts in the future.
    Ackness

  • Can we run application services when physical stand by database is in read

    can we run application services when physical stand by database is in read only mode
    i Want to up the EBS application services and check login when phyiscal standby database is in read only mode.
    Is it possible? for checking dataguard database application as well.

    but i just want to know that can i start EBS application services and nagivate the application.Without distrubing my primary database and application.You should not do as the moment you open the standby database it becomes invalid.
    Thanks,
    Hussein

  • I have a new IMAC 5k running Yosemite and when I log in I am asked a whole series of questions as to what keychain can access. How can I authorise all of these to be available upon login? Items concerned are such as "Talagent", "Messages agent" etc

    I have a new IMAC 5k running Yosemite and when I log in I am asked a whole series of questions as to what keychain can access. How can I authorise all of these to be available upon login? Items concerned are such as "Talagent", "Messages agent" etc

    Back up all data before proceeding.
    Launch the Keychain Access application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    Select the login keychain from the list on the left side of the Keychain Access window. If your default keychain has a different name, select that.
    If the lock icon in the top left corner of the window shows that the keychain is locked, click to unlock it. You'll be prompted for the keychain password, which is the same as your login password, unless you've changed it.
    Right-click or control-click the login entry in the list. From the menu that pops up, select
              Change Settings for Keychain "login"
    In the sheet that opens, uncheck both boxes, if not already unchecked.
    From the menu bar, select
              Keychain Access ▹ Preferences... ▹ First Aid
    There are four checkboxes in the window that opens. Check all of them. if they're not already checked. Close the window.
    Select
              Keychain Access ▹ Keychain First Aid
    from the menu bar and repair the keychain. Quit Keychain Access.
    If you use iCloud Keychain, open the iCloud preference pane and uncheck the Keychain box. You'll be prompted to delete the local iCloud keychain. Confirm. Then re-check the box. Follow one of the procedures described in this support article to set up iCloud Keychain on an additional device.

  • How can we enable tick icon when user click any button

    how can we enable tick icon when user click any button in captivate 6@

    hi first of all thanks for imitate action.
    actually i want to make a menu (TOC) with tick icons, on starting all ticks are disabled but when i click on any button from my menu i want to enable tick for that particular button so that user can know easily the visited button.

  • Finder window opens when user logs in

    I apologize if this has been answered previously - I can't find anything on this topic.
    Every time a user logs in to one of my eMacs - OS 10.4.10 (whether it be a local or network user) a new finder window opens that displays the users home. I would like this window to stop opening. I've read some responses that say to close the window then log out and the window should be gone when you log back in. That is not the case. I thought this solution my work on my local users but it doesn't work for either type of user.
    I'm trying to avoid writing a script to close the window. I'd like the window to just stop opening in the first place. I tried editing the finder.plist file and I can change what the window opens to, but I can't "turn off" the actual opening of the window.
    Any suggestions are greatly appreciated!
    Thanks!

    I do not have anything checked in the login items. This is happening for both local and network accounts. I'm more concerned about this issue for my network users.
    I've discovered that the problem seems to have something to do with a script I had running via a login hook. Is there any way to run a script when a network user logs in without adding it to a login hook?
    We have a program on our eMacs that resets the computer back t o its original state every time the computer is restarted. For this reason network user profiles are never stored on the eMac they are recreated from the default user template every time a user logs in.
    Maybe this extra information will help!
    Thanks!

  • Unable to capture trace, when user logs in throuigh Web Interface

    The Trace shows 'No Records Found', when user logs in through Web Interface of CRM. But there is Trace found, when the same user logs in through logon pad and carries out normal actvities.
    sufficient auth. is provided.
    Is there any setting in ST01, through which i can get trace , when user logs in through Web Interface
    Regards

    ST10 traces 1 instance only.
    Your CRM web interface could use another instance than your backend. Go to transaction SM21, choose the appropriate server and run ST10 again.
    Succes!
    Kind regards,
    Lodewijk Borsboom

  • Java dying when user logs off machine

    I have developed a class that monitors a MQ queue, I used the active-x bridge to allow distribution to both java and VB developers to use. The application that is to be developed should be running on a machine in the background.
    I created a test VB program using the java class and created a "scheduled task" to start on system start up. When I start the machine, the application starts up and runs. Then a user logs into the machine, and application is still running. Then the user logs off the machine, and the program stops.
    I have a VB porgram without the java active-x bridge object and that works throughout the login/logout process.
    Any thoughts on how I can keep the program running continously, thanks.

    Well, I found a solution. If you add the paramater -Xrs to the java command, it will reduce the use OS signals. Thus it will ignore the hook that Windows has.
    It turns out this was a bug in version 1.3. For some non-light reading and more info, see http://developer.java.sun.com/developer/bugParade/bugs/4323062.html

  • Copy apps using HFM Copy application utility when users logged in.

    Hi All
    I am using HFM copy application utility to migrate apps across environments. Can we do the same when users are logged in and active? I know that this utility just copies tables from source to destination, but I m not sure if the copy will be successful if some of the tables are being edited.
    Thankyou,
    Raghu

    Hi,
    Dont run the HFm Copy appplication utility when apps were in use.Let say you have app1,2,3,4 and you want to move app 1, make sure app 1 is not in use.
    if some body is accessing app2 or 3 or 4 you dont want to worry about that while moving app 1.
    Thanks,
    Mugundhan

Maybe you are looking for

  • Mac OS X Lion Macintosh HD is show's not correct data.

    Mac OS X Lion Macintosh HD is show's not correct data. Every time is changing the capacity. In Disk Utility everything is correct, but when i'm doing get info in Macintosh HD every 10 sec is growing up. I compare get info with disk utility in get

  • Captivate 4.0 - Need best practice tips on panning, templates, resolution, etc.

    Hi all, Been searching all over in case someone has already published Best Practices for Captivate 4.0 (particularly the new/enhanced features), but coming up empty. My client's in house graphics person has been tasked with creating a template for us

  • XSS SCA import in CMS error: failed to build

    We are getting error when trying to build XSS Track in NWDI. There are 2 brocken DC for development track. Here is the error message that we get: Development Component Build (2008-11-28 22:04:10)   Component name: mss/mol   Component vendor: sap.com

  • TS LabVIEW OI

    I am running a sequence file that calls VIs and I have the LabVIEW adapter set to LabVIEW Runtime Engine. Everything runs fine using the Sequence Editor and the User Interfaces(both modes) of all the languages except for the LabVIEW one. The problem

  • Confirmation Delete Workflow

    Hello all, I was wondering if we can trigger a workflow approval when a Confirmation is Deleted (reversed) in SRM 4.0 (Classic Scenario). The scenario is: 1) A desktop receiver performs confirmation. 2) No approval is required. So, a Goods Receipt is