parsing options with getopts
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > parsing options with getopts




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    parsing options with getopts  
Morten Seeberg


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-04-04 11:01 PM

Is there any way to use more descriptive options such as:

-option1 blabla -option2 blabla
instead of just
-o blabla -p blabla

I havent been able to find anything about it or make i work with getopts...

~~~~~~~~~~~~~~~
/\/\orten $eeberg

remove x for reply







[ Post a follow-up to this message ]



    Re: parsing options with getopts  
Eric Moors


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-04-04 11:01 PM

Morten Seeberg wrote:

> Is there any way to use more descriptive options such as:
>
> -option1 blabla -option2 blabla
> instead of just
> -o blabla -p blabla
>
> I havent been able to find anything about it or make i work with
> getopts...

At least for linux there is getopt.
A commandline parser to be used from scripts.
That can deal with long options
I am not sure about other OS's

Eric





[ Post a follow-up to this message ]



    Re: parsing options with getopts  
Morten Seeberg


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-04-04 11:01 PM

As I was still googling around, i noticed this being called longoptions, and
found the thread:
ksh'93 getopts --longoptions


"Morten Seeberg" <xml@seeberg.dk> wrote in message
news:sx88d.1963$ZH1.598@news.get2net.dk...
> Is there any way to use more descriptive options such as:
>
> -option1 blabla -option2 blabla
> instead of just
> -o blabla -p blabla
>
> I havent been able to find anything about it or make i work with
getopts...







[ Post a follow-up to this message ]



    Re: parsing options with getopts  
Dana French


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-04-04 11:01 PM

"Morten Seeberg" <xml@seeberg.dk> wrote in message news:<sx88d.1963$ZH1.598@news.get2net.dk>
..[vbcol=seagreen]
> Is there any way to use more descriptive options such as:
>
> -option1 blabla -option2 blabla
> instead of just
> -o blabla -p blabla
>
> I havent been able to find anything about it or make i work with getopts...[/vbcol
]


Some implementations of "getopts" will allow long options, however
that is not portable across platforms.  There is an example ksh93
function called "getwordopts_k93" that allows the use of words as
options at the following URL:

http://www.mtxia.com/fancyIndex/Too...x/find_k93.html

This function is not intended as a replacement for "getopts", it is
merely intended to solve a specific problem for the "find_k93"
function.  You may be able to modify this function for your specfic
needs.

--------------------------------------------------------
Dana French                            dfrench@mtxia.com
Mt Xia Technical Consulting Group   http://www.mtxia.com
100% Spam Free Email              http://www.ridmail.com
MicroEmacs                      http://uemacs.tripod.com
Korn Shell Web     http://dfrench.tripod.com/kshweb.html





[ Post a follow-up to this message ]



    Re: parsing options with getopts  
Janis Papanagnou


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-04-04 11:01 PM

Morten Seeberg wrote:[vbcol=seagreen]
> Is there any way to use more descriptive options such as:
>
> -option1 blabla -option2 blabla
> instead of just
> -o blabla -p blabla
>
> I havent been able to find anything about it or make i work with getopts...[/vbcol
]

As others pointed out already, ksh93 supports that feature.

The only somewhat elaborate source of documentation with
examples that I have found yet is a book of Rosenblatt
("Learning Korn Shell" was the title, I think).

Janis





[ Post a follow-up to this message ]



    Re: parsing options with getopts  
Eric Moors


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-07-04 07:56 AM

Morten Seeberg wrote:

> Is there any way to use more descriptive options such as:
>
> -option1 blabla -option2 blabla
> instead of just
> -o blabla -p blabla
>
> I havent been able to find anything about it or make i work with
> getopts...

At least for linux there is getopt.
A commandline parser to be used from scripts.
That can deal with long options
I am not sure about other OS's

Eric





[ Post a follow-up to this message ]



    Re: parsing options with getopts  
Morten Seeberg


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-07-04 07:56 AM

As I was still googling around, i noticed this being called longoptions, and
found the thread:
ksh'93 getopts --longoptions


"Morten Seeberg" <xml@seeberg.dk> wrote in message
news:sx88d.1963$ZH1.598@news.get2net.dk...
> Is there any way to use more descriptive options such as:
>
> -option1 blabla -option2 blabla
> instead of just
> -o blabla -p blabla
>
> I havent been able to find anything about it or make i work with
getopts...







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:17 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register