Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

skinicod

macrumors newbie
Original poster
Jul 6, 2013
2
0
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.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
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.

The absolute easiest way is to use login items, you just need to add your script there. It's in system preferences under accounts.
 

Dalton63841

macrumors 65816
Nov 27, 2010
1,449
8
SEMO, USA
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
 

skinicod

macrumors newbie
Original poster
Jul 6, 2013
2
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.