<br><font size=2 face="sans-serif">You want to use getopts, like this:</font>
<br>
<br><font size=2 face="sans-serif">while getopts ":c:h:j:" opt;
do</font>
<br><font size=2 face="sans-serif"> case $opt
in</font>
<br><font size=2 face="sans-serif">
"c")</font>
<br><font size=2 face="sans-serif">
echo do something with "-c"</font>
<br><font size=2 face="sans-serif">
;;</font>
<br><font size=2 face="sans-serif">
"h")</font>
<br><font size=2 face="sans-serif">
echo do something with "-h"</font>
<br><font size=2 face="sans-serif">
;;</font>
<br><font size=2 face="sans-serif">
"j")</font>
<br><font size=2 face="sans-serif">
echo do something with "-i"</font>
<br><font size=2 face="sans-serif">
;;</font>
<br><font size=2 face="sans-serif">
?)</font>
<br><font size=2 face="sans-serif">
echo -e "$opt isn't an option.
Try again."</font>
<br><font size=2 face="sans-serif">
exit 1</font>
<br><font size=2 face="sans-serif">
;;</font>
<br><font size=2 face="sans-serif"> esac</font>
<br><font size=2 face="sans-serif">done</font>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Jean Lee <jean.lee@free.fr></b>
</font>
<br><font size=1 face="sans-serif">Sent by: whitebox-users-bounces@beau.org</font>
<p><font size=1 face="sans-serif">05/25/2005 10:14 AM</font>
<td width=59%>
<table width=100%>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td valign=top><font size=1 face="sans-serif">whitebox <whitebox-users@beau.org></font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">[WBEL-users] script bash
and options</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2><tt>Hello,<br>
<br>
I would like to had an option when I launch my script in bash (like : <br>
backup.sh -c -h -j --usersdenied="kl")<br>
<br>
I know that an argument can be passed to a command line ($1, $2,....) <br>
but I don't know how to write the script properly to :<br>
- write the options in a different order (for example : backup.sh -j -h
<br>
-c ...)<br>
- write the options like this : -jhc<br>
- options may not be wrotten too.<br>
<br>
Or perhaps that I made a mistake and options are not arguments (like <br>
with : ls -l)<br>
<br>
Does anybody knows ?<br>
<br>
Thank you for your answer,<br>
<br>
Jean<br>
<br>
_______________________________________________<br>
Whitebox-users mailing list<br>
Whitebox-users@beau.org<br>
http://beau.org/mailman/listinfo/whitebox-users<br>
</tt></font>
<br>