loop problem in c shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting loop problem in c shell
# 1  
Old 09-20-2010
loop problem in c shell

Hi all,
i got problem with this statement. I use 2 time loop while in 1 statement . But it excetu at second loop while. I want it continue loop until it stop when wrong. Plz help me
--
Code:
#!/bin/csh

set app_dir = "/ebsxe/ebs25/users/mmlim/assignment01"

set line_array = (`cat $app_dir/config_path`)
set line_array_2 = (`cat $app_dir/config_recipient`)

@ index1 = 1
@ index2 = 2
@ index3 = 3

@ lot1 = 1
@ lot2 = 2

while ( $index1 && $index2 && $index3 <= $#line_array )

        set dir = $line_array[$index1]
        set limit = $line_array[$index2]
        set class = $line_array[$index3]

        cd $dir
        set filecount = ( `ls -1 | wc -l` )

                if ( $filecount <= $limit ) then
                        while ( $lot1 && $lot2 <= $#line_array_2 )
                         set group = $line_array_2[$lot1]
                         set email = $line_array_2[$lot2]

                        if ( $class == $group )then
                        echo " $email "
                        endif

                        @ lot1 +=1
                        @ lot2 +=2
                        continue
                        end

                else

                          while ( $lot1 && $lot2 <= $#line_array_2 )

                       if  ( $class == $group )then
                       echo " $email "
                       endif

                       @ lot1 +=2
                       @ lot2 +=2
          end    
                      
                endif

        @ index1 += 3
        @ index2 += 3
        @ index3 += 3

end

Thx

Last edited by Franklin52; 09-20-2010 at 05:45 AM.. Reason: code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with loop within loop

Hi, I work on Ab-initio ETL tool which is based on Unix. I made a small script which has two loop's one with in another. All the functionality is working for the first line of outer loop but when it comes to other lines of outer loop it is throwing error as command not found. Below is the... (4 Replies)
Discussion started by: Ravindra Swan
4 Replies

2. Shell Programming and Scripting

Bourne Shell - Problem with while loop variable scope.

Hello I am having issues with a script I'm working on developing on a Solaris machine. The script is intended to find out how many times a particular user (by given userid) has logged into the local system for more than one hour today. Here is my while loop: last $user | grep -v 'sshd'... (7 Replies)
Discussion started by: DaveRich
7 Replies

3. UNIX for Dummies Questions & Answers

C shell loop problem occur

Hi all, i create 2 file Config path1 5 group1 path2 6 group2 path3 10 group1 path4 15 group2 Confine group1 andrew group2 alan In my C shell script i write like this: set line_array = (`cat $app_dir/config`) set line_array_2 =... (0 Replies)
Discussion started by: proghack
0 Replies

4. Shell Programming and Scripting

while loop problem in c shell script

Hi all, i write a script c shell set i = 1 while ( $i <= $#array ) echo "$array" @ i++ end i want to set it to i = i +2 in that statement . Can anybody help me? ---------- Post updated at 02:46 PM ---------- Previous update was at 02:35 PM ---------- anybody not how to solve it??? (2 Replies)
Discussion started by: proghack
2 Replies

5. Shell Programming and Scripting

Problem with while loop in shell script

Hi All, How to read a file upto last line(End Of Line) I wrote below program: cat R2_20060719.610.txt | while read LINE do echo "$LINE" done above code reading all lines from a file and skipping last line...... is there anything wrong in my code. Please help me out from this... (20 Replies)
Discussion started by: rkrgarlapati
20 Replies

6. Shell Programming and Scripting

problem with while loop in BASH shell

I have file named script1 as follows: #!/bin/bash count="0" echo "hello" echo "$count" while do echo "$count" count=`expr $count + 1` done ----------- when I run it, I get ./script1: line 9: syntax error near unexpected token `done' ./script1: line 9: `done' I... (6 Replies)
Discussion started by: npatwardhan
6 Replies

7. Shell Programming and Scripting

if loop problem in bourne shell

how to use if-loop in bourne shell with multiple conditions like follows if then commands fi it gives me an error test: ] missing then i put if ] it gives me an error [[ not found kindly i need the syntex for the bourne shell (5 Replies)
Discussion started by: ahmad.diab
5 Replies

8. Solaris

Problem in for loop of shell scripting in solaris

Hi below is my script for((i=0;i<=$TOTAL;i++)) do echo "IP's created are $s1.$s2.$s3.$s4" s4=`expr $s4 + 1` done where s1,2,3,4 are input varibles below error occurs while running the script syntax error at lin 11: '(' unexpected ... (12 Replies)
Discussion started by: krevathi1912
12 Replies

9. Shell Programming and Scripting

for loop problem in K shell

I want to echo from 1 to 100 using a for loop. I was trying out all possible syntax using for loop, but it errors out. can you help me in doing this? I was using for i in 1..100 do echo $i done Regards Asutoshch (4 Replies)
Discussion started by: asutoshch
4 Replies

10. Shell Programming and Scripting

Shell Script loop problem

I am writing a shell script that simulates the `wc -w` command without actually using wc itself. My problem is that the script will only read the first line of the file and just keep looping through it. I have tried both while and for loops and got the same result. Can anyone help? ... (1 Reply)
Discussion started by: MaxMouse
1 Replies
Login or Register to Ask a Question