elseif in csh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting elseif in csh
# 1  
Old 07-02-2010
"elseif" or "else if" in csh

I have been using the if statement in csh like this

Code:
if ( $opt1 == 1 ) then
 .....

elseif ( $opt2 == 1 ) then

......
endif


Seems to work, but got

Badly placed ()'s.


When I used a space in the elseif, a space between the 'else' and the 'if' it worked

Code:
if ( $opt1 == 1 ) then
 .....

else if ( $opt2 == 1 ) then

......
endif

Any idea why the thing sometimes works and sometimes not???

Last edited by kristinu; 07-02-2010 at 11:26 AM.. Reason: Clarification
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Elseif & for condition in AIX

I'm using the below statements in my script if && then sqlplus sysadm/abcdefgh12@${dbarr} @/u1/scripts/ResetPswd.sql elif then for idx in 0 1 2 3 4 5 6 7 do sqlplus sysadm/abcdefgh12@${dbarr} @/u1/scripts/ResetPswd.sql done else exit fi It give me... (5 Replies)
Discussion started by: Pandee
5 Replies

2. Programming

Problem with IF ELSEIF and GOTO statements in FORTRAN

Hi I am reading a book about Fortran 90 and I write the following code, to test my understanding of the first chapter. I have a problem with the last section of the code with deals with an IF, ELSEIF, and GOTO statements. Here is my Code PROGRAM sim ! This code is used to solve two... (3 Replies)
Discussion started by: faizlo
3 Replies

3. Shell Programming and Scripting

What does this do in CSH?

CSH experts What does the following do in CSH? :(){:|:&};: I was asked the question, but I don't know. I'm not aware of the context. Any ideas? Thanks! (1 Reply)
Discussion started by: wallg
1 Replies

4. UNIX for Dummies Questions & Answers

If Then ElseIf Script - Confusion Around Expression's Syntax

Hello, I am relatively new to UNIX scripting and am learning a lot. I have already tried several searches on this website and have tried various syntax options suggested to no avail. I am obviously not writing the script correctly. I really do appreciate any and all the help. Below is an... (8 Replies)
Discussion started by: dqrgk0
8 Replies

5. Shell Programming and Scripting

if elseif fi

Hi, Ihave shifted this thread which i posted in linux forum to here if i am fault please correct me. When i excute this below script i am getting the follwing error can any one please look into it for persual. ./sample_oracle_tradescope.sh: 25: showDEFAULTUsage: not found ... (6 Replies)
Discussion started by: oracle_coorgi
6 Replies

6. Linux

if elseif fi

Hi all, This is my first post in this forum, can i request you to guide, where i am going wrong with the error below. 34: Syntax error: "fi" unexpected (expecting "then") #!/bin/sh argCount=0 mysql_path=$USER_INSTALL_DIR$ for i in $*; do /A argCount+=1 done if ;then echo... (2 Replies)
Discussion started by: oracle_coorgi
2 Replies

7. Shell Programming and Scripting

if in csh

I am using this code echo "opt_tpath = $opt_tpath" if ($opt_tpath == 1) echo " -tpath = $Atpath\n" and is giving opt_tpath = 0 Atpath: Undefined variable. Atpath should only be printed in opt_tpath == 1 but it still tries to print. ---------- Post updated at 10:05 AM ----------... (1 Reply)
Discussion started by: kristinu
1 Replies

8. Shell Programming and Scripting

Awk if elseif syntax error

Below is the code. nawk -F "|" 'FNR==NR{a=$3 OFS $4 OFS $5 OFS $6;next} {\ if ($5 in a)\ {print $1,"ABC",$5,"I",a, $2,$3,$4 OFS OFS OFS OFS OFS OFS OFS OFS $2"-"$3"-"$4} ; \ elseif ($5=="g")\ print $1,"ABC",$5,"I",$5 OFS OFS OFS OFS $2,$3,$4 OFS OFS OFS OFS OFS... (8 Replies)
Discussion started by: pinnacle
8 Replies

9. UNIX for Dummies Questions & Answers

csh

what is a .csh extension? there is a command line: mkaphed_ctio.csh Does anyone know what this is? :confused::confused::confused: (1 Reply)
Discussion started by: cosmologist
1 Replies

10. Shell Programming and Scripting

csh failing to call an 2 embedded csh script

I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them) Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Discussion started by: pollsizer
1 Replies
Login or Register to Ask a Question
if(n)							       Tcl Built-In Commands							     if(n)

__________________________________________________________________________________________________________________________________________________

NAME
if - Execute scripts conditionally SYNOPSIS
if expr1 ?then? body1 elseif expr2 ?then? body2 elseif ... ?else? ?bodyN? _________________________________________________________________ DESCRIPTION
The if command evaluates expr1 as an expression (in the same way that expr evaluates its argument). The value of the expression must be a boolean (a numeric value, where 0 is false and anything is true, or a string value such as true or yes for true and false or no for false); if it is true then body1 is executed by passing it to the Tcl interpreter. Otherwise expr2 is evaluated as an expression and if it is true then body2 is executed, and so on. If none of the expressions evaluates to true then bodyN is executed. The then and else arguments are optional "noise words" to make the command easier to read. There may be any number of elseif clauses, including zero. BodyN may also be omitted as long as else is omitted too. The return value from the command is the result of the body script that was executed, or an empty string if none of the expressions was non-zero and there was no bodyN. EXAMPLES
A simple conditional: if {$vbl == 1} { puts "vbl is one" } With an else-clause: if {$vbl == 1} { puts "vbl is one" } else { puts "vbl is not one" } With an elseif-clause too: if {$vbl == 1} { puts "vbl is one" } elseif {$vbl == 2} { puts "vbl is two" } else { puts "vbl is not one or two" } Remember, expressions can be multi-line, but in that case it can be a good idea to use the optional then keyword for clarity: if { $vbl == 1 || $vbl == 2 || $vbl == 3 } then { puts "vbl is one, two or three" } SEE ALSO
expr(n), for(n), foreach(n) KEYWORDS
boolean, conditional, else, false, if, true Tcl if(n)