Please help me with this script

ForLoop5
ForLoop5 used Ask the Experts™
on
I got some help with the script below.    But when I run the script I get an error that says "line 2: syntax error: unexpected end of file" Anyone know what is wrong?  I am running mac os 10.7.  I am saving the script as a .sh file and applying the chmod u+x permissions before running the script.

for USER in {ls -1 /Volumes/Data/Students}
do
echo rm -rf /Volumes/Data/Students/$USER/Library/Application\ Support/Adobe/Acrobat
echo rm -rf /Volumes/Data/Students/$USER/Library/Application\ Support/Adobe/Flash\ CS5
echo mkdir -p /Volumes/Data/Students/$USER/Library/Application\ Support/Adobe/Acrobat
echo ln -s /Users/Shared /Volumes/Data/Students/$USER/Library/Application\ Support/Adobe/Acrobat/9.0_x86
echo ln -s /Users/Shared /Volumes/Data/Students/$USER/Library/Application\ Support/Adobe/Flash\ CS5
echo cp -a /var/root/resources/com.adobe.acrobat.90.sh.plist /Volumes/Data/Students/$USER/Library/Preferences/
echo chmod 777 /Volumes/Data/Students/$USER/Library/Preferences/com.adobe.acrobat.90.sh.plist
done
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Arun Kumar VManager - IT Operations

Commented:
Try without space

echo rm -rf /Volumes/Data/Students/$USER/Library/Application\ Support/Adobe/Flash\CS5
echo ln -s /Users/Shared /Volumes/Data/Students/$USER/Library/Application\ Support/Adobe/Flash\CS5
change that first line to
for USER in `ls -1 /Volumes/Data/Students`

Open in new window


Make sure you are using the backquote (`) not the forward single quote (')

Commented:
The file extension and permissions have nothing to do with that error.  It tells you where to look....Line 2.  If that is your entire script, line 2 would be the "do" statement.  It's been a while since I did any scripting but isn't do a conditional statement?  Do...Until, or Do...While???  Also I was taught that the very first line should declaring the location and type of shell you are using for example:
          #!/bin/bash
The incorrect syntax provided by that "for" line caused the file to end on line 2.  If you don't have the #!/bin/bash first line, you can actually run your file using

sh FILENAME.sh

In the above case, it doesn't matter if you chmod +x the file.  Otherwise, tyum is correct.  You should use #!/bin/bash to set the shell environment if you want to execute it via a ./FILENAME.sh

The previous example I gave will work in sh or bash.  What you probably intended was a bash only syntax for running a command, which uses $(COMMAND), but you used braces which are used for ranges.
for USER in $(ls -1 /Volumes/Data/Students);

Open in new window

Here's an example using braces for ranges in bash.
for i in {1..9..2}; do echo $i ;done

Open in new window

would output
1
3
5
7
9

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial