Login Script

Discussion in 'OS X Mountain Lion (10.8)' started by Lew4484, Aug 22, 2013.

  1. Lew4484
    Expand Collapse
    macrumors newbie

    Mar 23, 2011
    Hi all, I am trying to produce a login script that will basically create a folder at startup, set it's permissions and also move a set of files to the users preferences folder when logging in with a network account (workgroup manager won't allow me to do this and the files are greyed out). I have also set a logouthook to delete the folder when then log out (it's to be used as a scratch disk). I find that the login script works fine when I run it manually as a network user, but when I set a loginhook, parts of the script work and it will create a folder and set it's permissions, but it will not copy the files over to the user preferences folder. After a bit of research I found that this may be because it is running as a root user and this will ignore paths such as ~/library/ (I'm a beginner in regards to shell scripts and programming, so please correct me if this is wrong). Does anybody know a more effective way to get this to work?

    Here is a copy of the script if you need it:


    mkdir "/Scratch/Scratch"
    chmod a+w /Scratch/Scratch
    cp -r /Library/Preferences/FinalCut/* ~/Library/Preferences

    The files being copied over are to basically set the scratch disk location in Final Cut to the temporary folder created at startup. The entire process is as follows,

    • Create folder in /Scratch called Scratch at startup to be used as a scratch disk
    • Set permissions to 'read and write' for all users
    • Move a set of files located in /Library/Preferences/FinalCut to the users preferences folder
    • Delete the scratch disk on log out

    If anyone sees a better way of achieving what I'm trying to do please let me know.
  2. tag
    Expand Collapse
    macrumors 6502a


    Apr 29, 2005
    PA, US
    Well according to this Apple Knowledge Base article, you are right that a login hook is executed as root. The article also states that the variable $1 returns the short name of the user who is logging in. So if you change the destination of the cp command this should work I would think....

     mkdir "/Scratch/Scratch"
     chmod a+w /Scratch/Scratch
     cp -r /Library/Preferences/FinalCut/* /Users/"$1"/Library/Preferences

Share This Page