LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-23-2004, 05:58 PM   #1
yulitao
LQ Newbie
 
Registered: Mar 2004
Posts: 18

Rep: Reputation: 0
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!
 
Old 03-23-2004, 06:13 PM   #2
zekko
Member
 
Registered: Aug 2003
Location: Canada
Distribution: Slackware, debian
Posts: 76

Rep: Reputation: 15
Depending what language you're doing it in? More information please.
 
Old 03-23-2004, 06:15 PM   #3
yulitao
LQ Newbie
 
Registered: Mar 2004
Posts: 18

Original Poster
Rep: Reputation: 0
bash shell in redhat
 
Old 03-23-2004, 06:42 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Code:
#!/bin/bash

NAME=$(basename $0)
if [ "$1" == "-h" ] ; then
        echo "Usage:  ${NAME} [-h]"
        echo "Option:"
        echo "  -h:  Print this help text"
        exit 0
fi
echo "You gave me these arguments: $*"
exit 0
 
Old 03-23-2004, 07:30 PM   #5
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to pass command-line parameter to shell script? Kropotkin Linux - Newbie 12 07-25-2011 09:24 AM
Change parameter of /etc/sysconfig/network with a script philipina Linux - Hardware 1 03-11-2004 12:59 PM
Change parameter of /etc/sysconfig/network with a script philipina Linux - General 3 03-11-2004 05:05 AM
How to change parameter values of a function in shell script? Bassam Programming 0 01-25-2004 09:52 AM
add user script? ezra143 Linux - Software 2 10-21-2003 11:21 PM


All times are GMT -5. The time now is 11:40 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration