LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-13-2012, 03:17 PM   #1
oracledb0101
LQ Newbie
 
Registered: Jun 2012
Posts: 3

Rep: Reputation: Disabled
CASE statement


Code:
case $GROUP_NAME in
        "HR" )
                echo "Primary"  >> $log
        ;;
        "ERP")
                if  $DEPT="ACCOUNTING";  then
                        echo "Secondary" >> $log
               else
               echo "The EXCEPTION DOES NOT WORK" >> $log
                fi
                ;;
        *)
esac
Above is my CASE statement and the exception doesn't see to work if $DEPT is something else rather than "ACCOUNTING", it seems it's on process the "IF" statement even $DEPT is not even in "ACCOUNTING"

Thanks
 
Old 06-13-2012, 03:58 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,404

Rep: Reputation: Disabled
The syntax of your if expression is wrong. Try:
Code:
if  [ "$DEPT" == "ACCOUNTING" ];  then
 
Old 06-13-2012, 04:13 PM   #3
oracledb0101
LQ Newbie
 
Registered: Jun 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
thanks

Last edited by oracledb0101; 06-13-2012 at 04:19 PM.
 
Old 06-13-2012, 04:15 PM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,404

Rep: Reputation: Disabled
Huh? If DEPT is not a variable, then what is it?

It doesn't make much sense to compare the text string "DEPT" to the text string "ACCOUNTING".
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] problem in case statement rit Linux - Newbie 2 03-25-2012 12:01 PM
Perl switch statement throwing error like Bad case statement (invalid case value?) kavil Programming 2 10-07-2010 05:50 AM
Case Statement craigjward Programming 6 12-13-2007 12:33 AM
Case statement with If statement cbo0485 Linux - Newbie 4 11-07-2007 09:05 PM
case statement baks Programming 2 03-15-2007 02:19 PM


All times are GMT -5. The time now is 02:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration