Foreach statement error in cshell

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Foreach statement error in cshell
# 1  
Old 07-06-2011
Question Foreach statement error in cshell

while executing the following c-shell script i got the error
"Couldn't find an 'end' to close a 'foreach' statement"
can't find the mistake ...plz help..

script ::

echo "enter build folder name in following sequence L-<REV>_<BUILD>"
set BUILD = $<
set file= `cat file1`
foreach i ($file)
 if (! -e N:\$BUILD\$i) then
  echo "$i not found"
  $i >> fail.txt
  echo "Copying $i"

Moderator's Comments:
Mod Comment Please use [CODE] tags when posting source listings, console output, ...
# 2  
Old 07-06-2011
make sure there is no space after the end and no emptyline after end
# 3  
Old 07-06-2011
CPU & Memory another error

Thanks for your reply but,
when I remove any new line after end. it gives me the following error.

"A newline is needed at the end of a command line. Hit end-of-file"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cshell if statement not working

Hi .I am trying to check the first arguments =-s and the third =-d,but it doesnt work ,any idea why It gives me if: Missing file name Thanks #case -s and files if( $1 == "-s" && $3 != "-d" ) then echo "case s" endif (1 Reply)
Discussion started by: lio123
1 Replies

2. Shell Programming and Scripting

Error in if statement

I am working on script for stale nfs. the file consists of cat data01stale.log - - - - /abcd/backup - - - - /abcd/data Script (16 Replies)
Discussion started by: nareshkumar522
16 Replies

3. Shell Programming and Scripting

CShell if statement

If I want to compare two string variables in csh how do I correctly implement it. For example I'm checking if on cmdln the $1 == -r do something. if($1 == -r) then code.... However when I run it I just get an error message "if: Missing file name". Any suggestions? (1 Reply)
Discussion started by: ROFL
1 Replies

4. Shell Programming and Scripting

Foreach loop. Error : Too many words from ``

Hi expert, I have a large text file :- number.txt 1 2 3 4 5 6 .... And i using csh foreach loop to read the file line by line. foreach line(`cat number.txt) set number = $line <Calculation> end (2 Replies)
Discussion started by: vincyoxy
2 Replies

5. Shell Programming and Scripting

C Shell - foreach - No Match error

Hi All, I am facing 'No Match' problem with foreach loop in C shell script. Initially I tried following grep command showing results properly as shown at the end of the Thread. But foreach command is throwing the error 'No match'. grep -n Inserted audit_file foreach insertstr (`grep -n... (0 Replies)
Discussion started by: adurga
0 Replies

6. UNIX for Dummies Questions & Answers

error in if statement

Hi, This is my script to catch any oracle errors. In this, the $sqlerr returns ORA-01017: invalid username/password; logon denied when i specify wrong username/password the if condition is failing. how can i resolve the issue. the if statement gives error sqloutput=`sqlplus -s -L... (1 Reply)
Discussion started by: Swapna173
1 Replies

7. UNIX for Dummies Questions & Answers

foreach statement in ksh

Hi, My script should run through all subdirs recursively in SUBDIR_LIST, run a clearcase command in each subdir, print to the merge_results1.txt and add a new line to the results before going to the next subdir. All the results should append to merge_results1.txt, but are seperated by a line so... (8 Replies)
Discussion started by: asulli01
8 Replies

8. Linux

error in if statement

Hi , I am getting an error when I run the script for checking word "view" in a file . I am using if statement. like this if then VW_VAR=` cat $TN.${ecmdate}.sql1 | grep -i view | awk '{print $3}' | cut -d '.' -f2 ` echo " VW_$VW_VAR " sed -e... (16 Replies)
Discussion started by: capri_drm
16 Replies

9. Shell Programming and Scripting

Error with if statement..Please help

:b:hi, I have a script as given below: pr_det="1" if then awk ' BEGIN {printf("%23s","session")}' >> report.txt awk ' BEGIN {printf "\n"} ' >> report.txt else awk ' BEGIN {printf("%55s","file_dsc")} ' >> report.txt awk ' BEGIN {printf("%101s","no_recs")} '... (1 Reply)
Discussion started by: jisha
1 Replies

10. Shell Programming and Scripting

foreach syntax error

I wrote a simplistic script which works fine in my HP Korn environment using for in do done but when I converted it for csh it is balking at my syntax specifically the parens for the argument. Any help would be appreciated set -x cut -f1 -d,... (3 Replies)
Discussion started by: r1500
3 Replies
Login or Register to Ask a Question