Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-23-2005, 10:18 AM   #1
LQ Newbie
Registered: Feb 2005
Posts: 18

Rep: Reputation: 0
Bash For Loops gives syntax error


I have typed in a bash script for a Firewall book by Robert Ziegler and I am debugging my typos and I am stuck on my latest.

The bash code hits a for loop

# Disable Source Routed Packets
for f in /proc/sys/net/ipv4/conf/*/accept_source_route; do
    echo 0 > $f
which gives a syntax error near unexpected token do'

I checked the line and its as printed. I've checked the directory wildcard and its correct for my distro (Fedora Core 3).

I've tried putting the do on the next line and stripping off the semi-colon but none of this corrects the behaviour.

Any ideas anyone, I'm stuck here until help is forthcoming.

Thanks in advance
Old 02-23-2005, 10:21 AM   #2
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 122Reputation: 122
The "do" must be on the same line as the first statement. Specifically, it must be part of the first statement.
Old 02-23-2005, 10:30 AM   #3
LQ Newbie
Registered: Feb 2005
Posts: 18

Original Poster
Rep: Reputation: 0
Thankyou very much.

Yes your suggestion fixes the problem and the following code works

# Disable Source Routed Packets
for f in /proc/sys/net/ipv4/conf/*/accept_source_route
do echo 0 > $f
Thanks again for fast response.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash, LS, For loops, and whitespaces in directories jhrbek Programming 27 09-22-2010 05:17 AM
bash scripting and loops phoeniks Programming 5 01-24-2005 04:00 PM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 06:09 PM
bash, loops and spaces in filenames shy Programming 5 11-08-2004 07:43 AM
bash - while + until loops grouping? trees Linux - General 2 02-19-2004 02:29 PM

All times are GMT -5. The time now is 06:09 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration