if else statement... need guide


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting if else statement... need guide
# 1  
Old 10-01-2012
if else statement... need guide

Code:
read readTerminal
terminal_c=$readTerminal
if [$terminal_c == 'B' || $terminal_c == 'K' || $terminal_c == 'T'];
 then
{
#Execute the first SQL query
}
else
echo next script
fi

anything wrong here?
# 2  
Old 10-01-2012
In the shell scripts if is also command. Looks like if in the programming languages but it's not same.
After if is some command, example test or shortly [ or compound command [[ or even cp or ...


Code:
if this_list_exit_value_is_0
then
       do_this
else
       # exit wasn't 0, so do
       something_not_ok
fi

Using test (= [ ) command
Code:
# argument delimiter between every elements in the command line
if [ $terminal_c = 'B' -o $terminal_c = 'K' -o $terminal_c = 'T' ]
then     
           # have to include 1 to N lines. : is the nop command
           echo "BKT"
else
            echo next script
fi

Or using [[ compound command
Code:
if [[ $terminal_c == 'B' || $terminal_c == 'K' || $terminal_c == 'T' ]]
then
           # have to include 1 to N lines. : is the nop command
           echo "BKT"

else
            echo next script
fi


Last edited by kshji; 10-01-2012 at 02:03 AM..
This User Gave Thanks to kshji For This Post:
# 3  
Old 10-01-2012
Quote:
Originally Posted by ment0smintz
Code:
read readTerminal
terminal_c=$readTerminal
if [$terminal_c == 'B' || $terminal_c == 'K' || $terminal_c == 'T'];
 then
{
#Execute the first SQL query
}
else
echo next script
fi

anything wrong here?
[QUOTE=ment0smintz;302708021]
Code:
read readTerminal
terminal_c=$readTerminal
if [ $terminalc = 'B' -o $terminalc = 'K' -o $terminalc = 'T' ]
 then
{
#Execute the first SQL query
}
elif [ $terminalc = 'P' -o $terminalc = 'Q' ] then
#Execute the second SQL query
else
echo next script
fi


Last edited by ment0smintz; 10-01-2012 at 05:09 AM.. Reason: solved
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. UNIX for Dummies Questions & Answers

Guide me please

Hi All, I am kinda struck at one point :wall: need ur help to move further. Query: My inputs files are Expected output: I am sure there should be similar tread relating my query ..but as i couldnt find the details i am posting again. Please direct me to the tread or reply... (1 Reply)
Discussion started by: unibeginner
1 Replies

3. Solaris

Best guide for Jumpstart

Hi Gurus, Can you please suggest me any good guides for a Beginner to learn Solaris Jumpstart. Thank You, Rama Krishna. (2 Replies)
Discussion started by: rama krishna
2 Replies

4. UNIX and Linux Applications

GD installation guide asking....

Hi, Does anybody success install GD and apply it in linux? I got trying to install it recently. Unfortunately, it seems like got a lot of error message shown :( Thus anybody got success install and use the GD in linux? Can share it with me? I'm using ia64 linux system. Thanks a lot for all... (6 Replies)
Discussion started by: patrick87
6 Replies

5. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

6. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

7. Solaris

Guide to Samba

Anyone have guide to install samba on solaris 9 I tried couple of times. --How do I go about uninstalling it? bash-2.05# testparm -s > output.file Load smb config files from /usr/local/samba/lib/smb.conf Processing section "" Processing section "" Loaded services file OK. bash-2.05#... (2 Replies)
Discussion started by: brabored
2 Replies

8. SCO

New to SCO -Guide me

Hello can any1 tell me the latest version of SCO. ALso can u give me some of the basic differences between Mandrake Linux and SCO Unix. (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question