-   Programming (
-   -   how to add -h parameter in script (

yulitao 03-23-2004 06:58 PM

how to add -h parameter in script
I have a script is "myscript",what shold I do if I want it show some help information when I run mysciprt -h!!!!!Thanks, I am a beginer!

zekko 03-23-2004 07:13 PM

Depending what language you're doing it in? More information please.

yulitao 03-23-2004 07:15 PM

bash shell in redhat

Hko 03-23-2004 07:42 PM



NAME=$(basename $0)
if [ "$1" == "-h" ] ; then
        echo "Usage:  ${NAME} [-h]"
        echo "Option:"
        echo "  -h:  Print this help text"
        exit 0
echo "You gave me these arguments: $*"
exit 0

aluser 03-23-2004 08:30 PM

You might also want to "man 1 getopt" for a more general way of taking comand line arguments. Unfortunately it's a little long and my system doesn't seem to have the examples mentioned in the doc :(

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