- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripts and 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
Forums
Discussions
Discussions
Discussions
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
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
08-06-2004 01:43 AM
08-06-2004 01:43 AM
#!/bin/sh
# An example with the case statement
# Reads a command from the user and processes it
echo "Enter your command (e.g. 724778:801)"
read command
case "$command" in
724778-801)
cp /hp3070/qm/pbq/$command/events A04940.txt
;;
724778:803)
cp /hp3070/qm/pbq/$command/events A04278.txt
;;
724782-801)
cp /hp3070/qm/pbq/$command/events A04615.txt
;;
99)
echo "exit"
?? (command to exit
;;
esac
Solved! Go to Solution.
- Tags:
- case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 01:47 AM
- Tags:
- exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 01:54 AM
08-06-2004 01:54 AM
Re: scripts and case statement
command=ok
while [ "$command" != "99" ]
do
your script
done
The do loop will repeat as long as command is not 99
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 03:30 AM
08-06-2004 03:30 AM
Re: scripts and case statement
And more if you are giving an unknown option then your script will not handle that one.
So use as like
*)
echo "Unknown options.. and your set of options"
exit 2
It will be very good on your script.
Muthukumar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2004 05:15 AM
08-06-2004 05:15 AM
Re: scripts and case statement
The following usually works fine:
while true; do
echo "Enter your command (e.g. 724778:801)"
read command
case $command in
...
...
99) break ;;
*) echo "Input error:<$command>" ;;
esac
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2005 02:06 AM
01-05-2005 02:06 AM