Shell Script Running and Password Problems

Discussion in 'Mac Programming' started by skinicod, Jul 6, 2013.

  1. macrumors newbie

    Joined:
    Jul 6, 2013
    #1
    Hello All,

    I have written the following script, which is intended to run at login:

    Code:
    mv /Library/"Application Support"/Digidesign/"Plug-Ins"/* /Library/"Application Support"/Digidesign/"Plug-Ins (Unused)"/
    
    file=~/Desktop/"Plugins List.txt"
    while IFS= read -r line
    do
            mv "/Library/Application Support/Digidesign/Plug-Ins (Unused)/$line" "/Library/Application Support/Digidesign/Plug-Ins/"
    done <"$file"
    mv "/Library/Application Support/Digidesign/Plug-Ins (Unused)"/XPand* "/Library/Application Support/Digidesign/Plug-Ins/"
    
    The code runs fine except for certain files I get the following feedback:

    Code:
    mv: rename /Library/Application Support/Digidesign/Plug-Ins (Unused)/Wurlitzer V.dpm to /Library/Application Support/Digidesign/Plug-Ins/Wurlitzer V.dpm: Permission denied
    I have changed the ownership of the shellscript to be root:admin, and added a line to my visudo:

    Code:
    # User privilege specification
    root    ALL=(ALL) ALL
    %admin  ALL=(ALL) ALL
    OldBoyMusic     ALL=(ALL) NOPASSWD:/plugin.sh
    Any ideas why these files are not copying? if I log into terminal as a root user I can move them with no problems at all.

    Secondly, does anyone know how I can get this script to run at login, I have tried setting up a plist in LaunchAgents, but this has not worked.

    Thanks in advance for your responses,

    cheers,

    skinicod.
     
  2. macrumors 68040

    Joined:
    Feb 2, 2008
    #2
    The absolute easiest way is to use login items, you just need to add your script there. It's in system preferences under accounts.
     
  3. macrumors 65816

    Dalton63841

    Joined:
    Nov 27, 2010
    Location:
    SEMO, USA
    #3
    Found this to help automate sudo commands. Might be worth giving a shot.

    Code:
    if [ $UID -ne 0 ]; then
    sudo $0
    else
    
    <SCRIPT GOES HERE>
    
    fi
     
  4. thread starter macrumors newbie

    Joined:
    Jul 6, 2013
    #4
    Amazing, thank you both - exactly what I needed. In case anyone is interested I found this link - which describes how to make a shellscript run in the background, by making it part of an AppleScript App.

    Thanks again,

    Skinicod.
     

Share This Page