Help with Apple script

Soldato
Joined
1 Sep 2005
Posts
10,001
Location
Scottish Highlands
Im trying to make an Apple script, but it keeps refusing to compile. This is the terminal code I want;

cd /System/Library/User\ Template/
sudo ditto -rsrcFork English.lproj/* English.lproj.bak
sudo rm -rf /System/Library/User\ Template/English.lproj/*
sudo cp -R /Users/default/* /System/Library/User\ Template/English.lproj/
sudo chown -R root English.lproj
sudo chgrp -R wheel English.lproj

Any idea where I'm going wrong?
 
Nope, no magic.

Copy the commands you want to use. Open a Terminal window. Enter
pico script.sh
to open a simple text editor and create a file called script.sh
Paste the commands
Press ctrl o to save, ctrl x to exit
make the script executable with
chmod +x script.sh
execute it with
./script.sh

It'll execute one line after another until it's done. :)
 
Ah, now theres an idea. Do you need any specific software to write a shell script, or can you do it in a text program like a windows batch file?

I use textwrangler see(http://www.barebones.com/products/textwrangler/download.html) it is a free cut down version of BBEdit. It saves as pure ascii unlike textedit that wants to save as RTF or similar.
After saving your text file you have to tell the OS it is executable by using chmod see (http://www.freeos.com/guides/lsst/ch02sec01.html).

HTH
 
I've found sometimes you need to run the script as root... Just do this:

sudo ./script.sh
I reccomend that too. You can then remove all the sudos in the text of the script.

For your copying convenience
Code:
cd /System/Library/User\ Template/
ditto -rsrcFork English.lproj/* English.lproj.bak
rm -rf /System/Library/User\ Template/English.lproj/*
cp -R /Users/default/* /System/Library/User\ Template/English.lproj/
chown -R root English.lproj
chgrp -R wheel English.lproj
 
Back
Top Bottom