LinuxQuestions.org
Help answer threads with 0 replies.
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 03-15-2010, 01:43 AM   #1
srinivas_uga
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Probem with case statement in shel programing


Hi Friends,

I am facing problem with the following script. Could you please look into this.

echo 'Enter Staging number'
case $STGNUM in
1)
for i in {'stg1-greg','stg1-marsha','stg1-peter','stg1-jan','stg2-greg','stg2-marsha','stg2-peter','stg2-jan'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/workflow/stopwf.sh;done;
for i in {'stg1-greg','stg2-greg'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/wfjmssf/stopwfjms.sh;done;
for i in {'stg1-greg','stg2-greg'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/wfjmssf/runwfjms.sh;done;
for i in {'stg1-greg','stg1-marsha','stg1-peter','stg1-jan','stg2-greg','stg2-marsha','stg2-peter','stg2-jan'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/workflow/runwf.sh;done;

3)
for i in {'stg3-greg','stg3-marsha','stg3-peter','stg3-jan','stg4-greg','stg4-marsha','stg4-peter','stg4-jan'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/workflow/stopwf.sh;done;

for i in {'stg3-greg','stg4-greg'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/wfjmssf/stopwfjms.sh;done;

for i in {'stg3-greg','stg4-greg'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/wfjmssf/runwfjms.sh;done;

for i in {'stg3-greg','stg3-marsha','stg3-peter','stg3-jan','stg4-greg','stg4-marsha','stg4-peter','stg4-jan'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/workflow/runwf.sh;done;



7)
for i in {'stg7-greg','stg7-marsha','stg7-peter','stg7-jan','stg8-greg','stg8-marsha','stg8-peter','stg8-jan'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/workflow/stopwf.sh;done;

for i in {'stg7-greg','stg8-greg'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/wfjmssf/stopwfjms.sh;done;

for i in {'stg7-greg','stg8-greg'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/wfjmssf/runwfjms.sh;done;

for i in {'stg7-greg','stg7-marsha','stg7-peter','stg7-jan','stg8-greg','stg8-marsha','stg8-peter','stg8-jan'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/workflow/runwf.sh;done;


9)
for i in {'stg9-greg','stg9-marsha','stg9-peter','stg9-jan','stg10-greg','stg10-marsha','stg10-peter','stg10-jan'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/workflow/stopwf.sh;done;

for i in {'stg9-greg','stg10-greg'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/wfjmssf/stopwfjms.sh;done;

for i in {'stg9-greg','stg10-greg'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/wfjmssf/runwfjms.sh;done;

for i in {'stg9-greg','stg9-marsha','stg9-peter','stg9-jan','stg10-greg','stg10-marsha','stg10-peter','stg10-jan'};do echo $i; ssh $i sudo -u dev /opt/usr/apps/workflow/runwf.sh;done;

*)
echo "entered wrong staging no"
esac


Error:

[suga@stg7-greg workflow]$ dev ./Test1.sh
Enter Staging number
./Test1.sh: line 9: syntax error near unexpected token `)'
./Test1.sh: line 9: `3)'


Thanks,
U.Srinivas
 
Old 03-15-2010, 01:52 AM   #2
mario.almeida
Member
 
Registered: May 2008
Location: India
Distribution: Ubuntu 10.04, CentOS, Manjaro
Posts: 179

Rep: Reputation: 27
Hi,
Your are missing --> ;; after each case

case $1 in

1)
do something ;
do something ;; <--
2)
do something ;
do something ;; <--
esac
 
Old 03-15-2010, 04:09 AM   #3
AngTheo789
Member
 
Registered: Sep 2009
Posts: 110

Rep: Reputation: 24
As a matter of fact, I would even make a distinct function for the similar lines. That would make the code easier to read, maintain and to extend.
 
  


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
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
problematic case statement alaios Programming 4 08-24-2005 09:05 AM
Shel scripting: variables pointing to variables and case Dark_Helmet Programming 5 06-08-2003 11:07 AM

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

All times are GMT -5. The time now is 09:15 PM.

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