LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 02: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, 02:58 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

Rep: Reputation: Disabled
The syntax of your if expression is wrong. Try:
Code:
if  [ "$DEPT" == "ACCOUNTING" ];  then
 
Old 06-13-2012, 03: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 03:19 PM.
 
Old 06-13-2012, 03:15 PM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

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



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 11:01 AM
Perl switch statement throwing error like Bad case statement (invalid case value?) kavil Programming 2 10-07-2010 04:50 AM
Case Statement craigjward Programming 6 12-12-2007 11:33 PM
Case statement with If statement cbo0485 Linux - Newbie 4 11-07-2007 08:05 PM
case statement baks Programming 2 03-15-2007 01:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:45 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
Open Source Consulting | Domain Registration