- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- case statement in a case statement
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2006 09:32 PM
тАО04-04-2006 09:32 PM
case statement in a case statement
For example in the following script i get a syntax error but i am pretty sure its caused due to the fact that it doesnt like the case into case statement: (see attachment)
Any comments are much appreciated.
- Tags:
- case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2006 09:45 PM
тАО04-04-2006 09:45 PM
Re: case statement in a case statement
I forgot to put ;; after the inner case statement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2006 09:51 PM
тАО04-04-2006 09:51 PM
Re: case statement in a case statement
#!/bin/ksh
echo "What LAN card would you like to adjust: "
read card
case "$card" in
[Ee][Tt][Hh]0)
lc=eth0
;;
[Ee][Tt][Hh]1)
lc=eth1
;;
[Ee][Tt][Hh]2)
lc=eth2
;;
[Ee][Tt][Hh]3)
lc=eth3
;;
[Ee][Tt][Hh]4)
lc=eth4
;;
[Ee][Tt][Hh]5)
lc=eth5
;;
[Ee][Tt][Hh]6)
lc=eth6
;;
*)
echo "Wrong LAN card, exiting"
exit 1
;;
esac
spe=`ethtool $lc | grep -i speed | awk '{print $2}'`
dup=`ethtool $lc | grep -i duplex | awk '{print $2}'`
neg=`ethtool $lc | grep Auto | grep -v autog| awk '{print $2}'`
echo "Current settings are:"
echo
echo "Card speed(S) is: $spe"
echo "Mode(M) is: $dup"
echo "Speed Negotiation(SN) is: $neg"
echo
echo "What would you like to change (S/M/SN): "
read choice
case "$choice" in
[Ss])
echo "What card speed(10/100/1000) would you like?: "
read cs
case "$cs" in
10)
ethtool -s $lc speed 10 duplex $dup autoneg $neg
;;
100)
ethtool -s $lc speed 100 duplex $dup autoneg $neg
;;
1000)
ethtool -s $lc speed 1000 duplex $dup autoneg $neg
;;
*)
echo "Incorrect speed, exiting"
exit 1
;;
esac
;; # ADDED
[Mm])
echo "What mode(FD/HD) would you like?: "
read lm
case "$lm" in
[Ff][Dd])
ethtool -s $lc speed $spe duplex full autoneg $neg
;;
[Hh][Dd])
ethtool -s $lc speed $spe duplex half autoneg $neg
;;
*)
echo "Incorrect mode, exiting"
exit 1
;;
esac
;; # ADDED
[Ss][Nn])
echo "What would you like AutoNegotiation(ON/OFF) to be?: "
read an
case "$an" in
[Oo][Nn])
ethtool -s $lc speed $spe duplex $dup autoneg on
;;
[Oo][Ff][Ff])
ethtool -s $lc speed $spe duplex $dup autoneg off
;;
*)
echo "Incorrect choice, exiting"
exit 1
;;
esac
;; # ADDED
*)
echo "Incorrect choice, exiting"
exit 1
esac
exit 0
## END ###
# ADDED gives new lines added.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2006 09:56 PM
тАО04-04-2006 09:56 PM
Re: case statement in a case statement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2006 09:57 PM
тАО04-04-2006 09:57 PM
Re: case statement in a case statement
A tip to you: Use sh -x <script> to get debugging informations always.
Keep posting.
--
Muthu