HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script Help
Operating System - HP-UX
1832961
Members
3356
Online
110048
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
11-17-2008 07:11 AM
11-17-2008 07:11 AM
Script Help
Can some one help me understand the following script?
#-----------------
# functions
#-----------------
function Usage {
echo "\nUsage: $1 [ -h ] \n"
echo "where"
echo " -h = prints this message"
echo "example: $1 \n "
}
#-----------------
# Collect the input variables. Check to see if they are correct.
while getopts ":h" PARAMETER; do
case $PARAMETER in
h) # Need some help.
Usage $0
exit 1
;;
\?)
Usage $0
exit 1
;;
esac
done
# Cleanout the variable list
shift $(($OPTIND - 1))
This is in the beginning of the vg, lv creation scripts? Can some one please help me understand what this part of script does?
#-----------------
# functions
#-----------------
function Usage {
echo "\nUsage: $1 [ -h ] \n"
echo "where"
echo " -h = prints this message"
echo "example: $1 \n "
}
#-----------------
# Collect the input variables. Check to see if they are correct.
while getopts ":h" PARAMETER; do
case $PARAMETER in
h) # Need some help.
Usage $0
exit 1
;;
\?)
Usage $0
exit 1
;;
esac
done
# Cleanout the variable list
shift $(($OPTIND - 1))
This is in the beginning of the vg, lv creation scripts? Can some one please help me understand what this part of script does?
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2008 07:19 AM
11-17-2008 07:19 AM
Re: Script Help
This script calls getopts(1) to crack the input line. It is looking for "-h" and invoking the help message in the function Usage.
Unrecognized options goto the "?" case.
After that is done, it shifts off the processed args, for OPTIND -1 args.
Unrecognized options goto the "?" case.
After that is done, it shifts off the processed args, for OPTIND -1 args.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2008 07:24 AM
11-17-2008 07:24 AM
Re: Script Help
Hi:
This is a standard way of processing commandline switches and arguments. In this case, only one optional switch ('-h') is allowed. Specifying '-h', or for that matter, any other flag or switch (an letter beginning with a hyphen) prints the name of the script and a usage message and then exits.
Regards!
...JRF...
This is a standard way of processing commandline switches and arguments. In this case, only one optional switch ('-h') is allowed. Specifying '-h', or for that matter, any other flag or switch (an letter beginning with a hyphen) prints the name of the script and a usage message and then exits.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2008 09:19 AM
11-17-2008 09:19 AM
Re: Script Help
Hi (again):
By the way, in case it wasn't clear, Dennis pointed you to the manpages for 'getopts' and those for 'sh-posix':
http://docs.hp.com/en/B2355-60130/getopts.1.html
http://docs.hp.com/en/B2355-60130/sh-posix.1.html
On the shell manpage, see also the information about OPTARG, OPTERR and OPTIND.
Regards!
...JRF...
By the way, in case it wasn't clear, Dennis pointed you to the manpages for 'getopts' and those for 'sh-posix':
http://docs.hp.com/en/B2355-60130/getopts.1.html
http://docs.hp.com/en/B2355-60130/sh-posix.1.html
On the shell manpage, see also the information about OPTARG, OPTERR and OPTIND.
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP