The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
May 18th, 2024, 12:16pm
Pages: 1
Send Topic Print
foreach command cshell scripting (Read 973 times)
avlsi
Community Member
***
Offline



Posts: 91
singapore
foreach command cshell scripting
Feb 17th, 2010, 10:43pm
 
Hi everyone,

                  In my cshell script, there are few foreach loops in which few commands gets executed. It is written as

foreach vds ( 1.1 1.2)
foreach temp ( 27.0 126.0)
commands
...
end
end

But when i execute the script by sourcing it..There are errors saying
foreach: Words not parentisized

Please help me to solve the error.

Thanks in advance.
Back to top
 
 

Winners never Quit,Quitters never Win
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: foreach command cshell scripting
Reply #1 - Feb 17th, 2010, 11:51pm
 
What you typed looks okay to me. Use
Code:
set echo 

before the for loops to see on which statement the error occurs.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
avlsi
Community Member
***
Offline



Posts: 91
singapore
Re: foreach command cshell scripting
Reply #2 - Feb 18th, 2010, 12:12am
 
Hi Ken,

          when i put echo in front of foreach loops.The error is Badly Placed ()'s.

          One more issue in my cshell script is, i have commands like mkdir file1. But the created directory name is file1? . I dont understand why the file is created in this way.

Thanks for ur prompt reply.
Back to top
 
 

Winners never Quit,Quitters never Win
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: foreach command cshell scripting
Reply #3 - Feb 18th, 2010, 5:07am
 
avlsi,
You probably have an invisible control character at the end of your line, e.g. CR (^M, 0x0D).
BOE
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: foreach command cshell scripting
Reply #4 - Feb 18th, 2010, 12:49pm
 
I was suggesting that you use echo to identify the offending line.

Avlsi might be on to something. Perhaps you are using a file formatted for windows or mac on unix, or visaversa. Try opening the file in vi, then type
:set ff=unix
:wq
and try again.

Is there some reason why you don't just post the script? It would be much easier to help you if we did not have to guess what you were doing.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.