have a problem with if elif loop .. plz help me with the script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers have a problem with if elif loop .. plz help me with the script
# 1  
Old 11-01-2007
have a problem with if elif loop .. plz help me with the script

count2=0
var2=NOT

if [ $count2 -eq 0 ]
then
echo"Loop1"
command="egrep ',$var1,"
if [ "$var2" = "OR" ]
then
echo "the command is OR"
command=$command"|,$var3,"
echo "$command"
elif [ "$var2 = "AND" ]
then
command=$command"| egrep ',$var3,"
else
echo "the command is NOT"
command=$command"| egrep -v ',$var3,"
echo "$command"
fi
else
echo "Loop2"
fi

I m getting the error 'end of file' unexpected and not able to proceed further.. Plz help me with this. Teh script and the syntax looks fine to me... But dunno where the mistake is
Smilie
# 2  
Old 11-01-2007
In this statement:
Code:
command=$command"|,$var3,"

are you trying to append some text to the existing variable?

If that is the case, then use the following syntax to append a value to an existing variable:
Code:
NAME=$NAMEappend_value

same applies to these statements:
command=$command"| egrep ',$var3,"
command=$command"| egrep -v ',$var3,"
# 3  
Old 11-01-2007
hi
tried using append command it does not work.. i m using korn shell.
And can u plx suggest a solution for if elif loop problem..?
# 4  
Old 11-01-2007
change this:
Code:
elif [ "$var2 = "AND" ]

to this:
Code:
elif [ "$var2" = "AND" ]

# 5  
Old 11-01-2007
thanks a lot...... Its working :-)
 
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 elif and else

Hello experts, I am having problems with ELIF. Please see the below code : read a; read b; read c; if || || ; then echo "EQUILATERAL" elif || || ; then echo "SCALENE" else echo "ISOSCELES" fi This code works fine for the EQUILATERAL case but fails completely for the... (5 Replies)
Discussion started by: H squared
5 Replies

2. Shell Programming and Scripting

PERL script loop problem

I have written the below PERL script to reprocess messages from a failure queue. It basically browses all the messages in the failure queue to individual files in a directory and then scans those files to determine the originating queue. The script will then move each message in turn from the... (0 Replies)
Discussion started by: chris01010
0 Replies

3. Shell Programming and Scripting

Problem with nested if...elif..else

Hi, I'm developing a script which will have a lot of options to be checked for and will be setting things / doing further things accordingly. I'm using a LOT of nested if, elif, else throughout my script. In some cases 5 to 6 levels deep. I'm facing some very basic problems. I've torn my... (4 Replies)
Discussion started by: umar.shaikh
4 Replies

4. UNIX for Dummies Questions & Answers

simple script with while loop getting problem

Hello forum memebers. can you correct the simple while program. #! /bin/ksh count=10 while do echo $count count='expr$count-1' done I think it will print 10 to 1 numbers but it running for indefinite times. (2 Replies)
Discussion started by: rajkumar_g
2 Replies

5. Shell Programming and Scripting

simple shell script with elif and for nexxt

Hi! I have here a simple script to change the advskew on carp interfaces. The first is working, but the part for status, where a for is within a if/else delivers everyime only the action for the value "prod". Even when i use type test or dev. Where did i made the mistake? # $Log:... (2 Replies)
Discussion started by: locutus01
2 Replies

6. 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

7. UNIX for Dummies Questions & Answers

if elif loop with read

I am trying to setup an if, elif statement that is dependant on a variable. If the user does not enter a valid option I would like it to prompt them again and start the loop over. Here is what I have so far: echo -n "enter variable (a, b, or c): " read freq if ; then echo "a" elif ;... (2 Replies)
Discussion started by: BStanley346
2 Replies

8. Shell Programming and Scripting

problem in while loop in a script

i have a script that will read each line and then grep a particular pattern and do some_stuff. Below the script while read j do q1=0 q1=`$j | grep 'INFO - LPBatch:' | wc -l` if then $j | tr -s " " | cut -d " " -f8,42,43 >> nav1.txt fi q2=0 q2=`$j | grep 'INFO - Number of Intervals... (12 Replies)
Discussion started by: ali560045
12 Replies

9. Shell Programming and Scripting

UNIX script problem ..Plz help ASAP

Hi folks, I have written down a UNIX script which actually FTP the file to other server. What is happening now , this script is not working only for 1 server , as it is working for 32 different FTP server . In this particular server , we are getting message “FTp:550 access denied”... (1 Reply)
Discussion started by: khan1978
1 Replies

10. Shell Programming and Scripting

NEED HELP PLZ! While Loop script needed!

PLZ Help us. I need to write a "while loop" script in borne shell to go into the /tmp directory every second and update me with the size of every file in the temp directory. My boss sprung this on me today and I have to have the script done by tomorrow. I can't loose my job, cause my wife and I... (1 Reply)
Discussion started by: scoobydoo
1 Replies
Login or Register to Ask a Question