It is currently Mon, 25 Sep 2023 10:53:45 GMT



 
Author Message
 Command line args

Hi,

I'm trying to write a csh script which will allow the user to put
switches with arguments on the command line in any order. The command
would be something like:

    % command -abc 1 -def 2 3 4 -ghijk 5

Does anyone have a csh routine which will do this?

Thanks in advance.
--
Kevin Reardon

Turnpike evaluation. For Turnpike information, mailto:i...@turnpike.com



 Thu, 20 Apr 2000 03:00:00 GMT   
 Command line args

        Ouch! That would take some funky scripting to cover all cases
and deal with bad data, user error.
        I suggest that you switch to using C/C++ and using the getopt()
function call or use perl (v5.x) and using GetOpt perl module.
        If you insist on using csh, then I suggest that you simplify:
Insist that users pass single options after the dash.
        ls -a -l        is much easier to deal with in code than
        ls -al

        However, I have not worked much with csh and little with options,
so my opinion/suggestion may not be worth much.

Sajjad

: Hi,

: I'm trying to write a csh script which will allow the user to put
: switches with arguments on the command line in any order. The command
: would be something like:

:     % command -abc 1 -def 2 3 4 -ghijk 5

: Does anyone have a csh routine which will do this?

: Thanks in advance.
: --
: Kevin Reardon

: Turnpike evaluation. For Turnpike information, mailto:i...@turnpike.com



 Fri, 21 Apr 2000 03:00:00 GMT   
 Command line args

Or, you can use either the sh/ksh builtin getopts; or solaris
provides an executable for csh.  See getopts(1) for all the
details, and a sample in sh/ksh.



 Fri, 21 Apr 2000 03:00:00 GMT   
 Command line args

How about a case statement and some shifts all inside a while $# > 0
loop?



 Sat, 22 Apr 2000 03:00:00 GMT   
 
   [ 4 post ] 

Similar Threads

1. CGI commands with command line args?

2. how to set argv command line args for ps

3. Script/Command line args for FTP needed!!

4. How to hide command line args under Solaris

5. Command-line args in C

6. command line args and 'if'


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software