LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

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

Rep: Reputation: 0
Bash For Loops gives syntax error


Hello,

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

Code:
# Disable Source Routed Packets
for f in /proc/sys/net/ipv4/conf/*/accept_source_route; do
    echo 0 > $f
done
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
Meadensi
 
Old 02-23-2005, 10:21 AM   #2
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,506

Rep: Reputation: 116Reputation: 116
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
meadensi
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

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


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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 07:47 PM.

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