Command line parameter checking?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Command line parameter checking?

Hybrid View

  1. #1
    Volker Held Guest

    Command line parameter checking?

    Hi,

    does anybody has a "good" example for
    command line parameter checking?

    I write a lot of command line tools for
    java, recently they have become more
    complex and itīs required to check a
    number of command line switches in order
    to provide successfull execution of the
    program.

    Now the checking in general is no
    problem, but iīm uneasy about which
    design approach to use...

    Until now i usually used an launcher
    class that passes the command line args
    to a "validating" module ( class ) that
    also sets the class fields if the args
    were correct.
    I used to set the class fields in the
    constructor of the "validating" class
    and a lot more... that is i do a lot of
    preparation/work in the constructor...
    now i ask myself is that really a good
    way to go or are there better/more
    efficient ways...

    Thanks for any advice

    Volker


  2. #2
    Per Guest

    Re: Command line parameter checking?


    Maybe it would be an idea to use xml. You could make an xml file with the
    setup condition and then use an xml parser like the one from ibm (free).
    Some of the validating could then be performed with the xml's dtd (this validating
    is automatic performed by the ibm parser).

    If you make use of xml to hold the setup values it can esaly be changed if
    you need other values to your application and you will have a great overview
    of the data.
    If you have not worked with xml and dtd it will take some time to understand
    it, but xml and java is working very good together and you will be able to
    find a lot of java software on the net that can performe the parsing.

    To take a quick look at xml see
    http://www.w3schools.com/
    There is no java parser on this link.


    regards
    Per
    Volker Held <vheld@gwdg.de> wrote:
    >Hi,
    >
    >does anybody has a "good" example for
    >command line parameter checking?
    >
    >I write a lot of command line tools for
    >java, recently they have become more
    >complex and itīs required to check a
    >number of command line switches in order
    >to provide successfull execution of the
    >program.
    >
    >Now the checking in general is no
    >problem, but iīm uneasy about which
    >design approach to use...
    >
    >Until now i usually used an launcher
    >class that passes the command line args
    >to a "validating" module ( class ) that
    >also sets the class fields if the args
    >were correct.
    >I used to set the class fields in the
    >constructor of the "validating" class
    >and a lot more... that is i do a lot of
    >preparation/work in the constructor...
    >now i ask myself is that really a good
    >way to go or are there better/more
    >efficient ways...
    >
    >Thanks for any advice
    >
    >Volker
    >



  3. #3
    Volker Held Guest

    Re: Command line parameter checking?

    Hello again Per,

    XML is a great idea, havenīt thought of
    using it for configuration files yet,
    despite the fact that iīm familiar with
    parsing XML.

    But the main problem is that ( i try to
    cut it short ) i have to program an
    application that will port XML sources
    into a relational DB ( MySQL ) and it
    has been specified as a command-line tool.
    Even if i write the URL to the DB into
    an XML config file, i still have the
    problem with authorisation.
    Use of the program will be restriced to
    a few people ( who in detail is yet
    unknown and shall be coded flexible ).
    Maybe iīm wrong, but in this case i
    think the best way to provide different
    user access is to get the username and
    password by using the command line
    params ( String[] args ) - and iīm
    looking for an effective way to check
    those...

    Per wrote:
    > Maybe it would be an idea to use xml. You could make an xml file with the
    > setup condition and then use an xml parser like the one from ibm (free).
    > Some of the validating could then be performed with the xml's dtd (this validating
    > is automatic performed by the ibm parser).
    >
    > If you make use of xml to hold the setup values it can esaly be changed if
    > you need other values to your application and you will have a great overview
    > of the data.
    > If you have not worked with xml and dtd it will take some time to understand
    > it, but xml and java is working very good together and you will be able to
    > find a lot of java software on the net that can performe the parsing.
    >
    > To take a quick look at xml see
    > http://www.w3schools.com/
    > There is no java parser on this link.
    >
    >
    > regards
    > Per
    > Volker Held <vheld@gwdg.de> wrote:
    >
    >>Hi,
    >>
    >>does anybody has a "good" example for
    >>command line parameter checking?
    >>
    >>I write a lot of command line tools for
    >>java, recently they have become more
    >>complex and itīs required to check a
    >>number of command line switches in order
    >>to provide successfull execution of the
    >>program.
    >>
    >>Now the checking in general is no
    >>problem, but iīm uneasy about which
    >>design approach to use...
    >>
    >>Until now i usually used an launcher
    >>class that passes the command line args
    >>to a "validating" module ( class ) that
    >>also sets the class fields if the args
    >>were correct.
    >>I used to set the class fields in the
    >>constructor of the "validating" class
    >>and a lot more... that is i do a lot of
    >>preparation/work in the constructor...
    >>now i ask myself is that really a good
    >>way to go or are there better/more
    >>efficient ways...
    >>
    >>Thanks for any advice
    >>
    >>Volker
    >>

    >
    >



  4. #4
    Per Guest

    Re: Command line parameter checking?


    Hi again
    Ohh sorry I misunderstood you.
    Hmmm, I have no experience with that myself.
    But if you take the input (username, password....) via the command line,
    then as I see it you will create an instance of the class each time a user
    is tryig to connect. And if a user is trying to connect with an illigal password
    he/she will course manuy objects to be created. I know that the garbage collector
    will eliminate them, but still.
    And if one is using an illigal password then as I see it you will not be
    able to count the number of tryings this could be a problem if a hacker is
    trying to get access.
    I do not no if any of this could be a problem for you and as I said I do
    not have any experience with this my self so I can be of no help - sorry

    Good luck
    Per


    Volker Held <vheld@gwdg.de> wrote:
    >Hello again Per,
    >
    >XML is a great idea, havenīt thought of
    >using it for configuration files yet,
    >despite the fact that iīm familiar with
    >parsing XML.
    >
    >But the main problem is that ( i try to
    >cut it short ) i have to program an
    >application that will port XML sources
    >into a relational DB ( MySQL ) and it
    >has been specified as a command-line tool.
    >Even if i write the URL to the DB into
    >an XML config file, i still have the
    >problem with authorisation.
    >Use of the program will be restriced to
    >a few people ( who in detail is yet
    >unknown and shall be coded flexible ).
    >Maybe iīm wrong, but in this case i
    >think the best way to provide different
    >user access is to get the username and
    >password by using the command line
    >params ( String[] args ) - and iīm
    >looking for an effective way to check
    >those...
    >
    >Per wrote:
    >> Maybe it would be an idea to use xml. You could make an xml file with

    the
    >> setup condition and then use an xml parser like the one from ibm (free).
    >> Some of the validating could then be performed with the xml's dtd (this

    validating
    >> is automatic performed by the ibm parser).
    >>
    >> If you make use of xml to hold the setup values it can esaly be changed

    if
    >> you need other values to your application and you will have a great overview
    >> of the data.
    >> If you have not worked with xml and dtd it will take some time to understand
    >> it, but xml and java is working very good together and you will be able

    to
    >> find a lot of java software on the net that can performe the parsing.
    >>
    >> To take a quick look at xml see
    >> http://www.w3schools.com/
    >> There is no java parser on this link.
    >>
    >>
    >> regards
    >> Per
    >> Volker Held <vheld@gwdg.de> wrote:
    >>
    >>>Hi,
    >>>
    >>>does anybody has a "good" example for
    >>>command line parameter checking?
    >>>
    >>>I write a lot of command line tools for
    >>>java, recently they have become more
    >>>complex and itīs required to check a
    >>>number of command line switches in order
    >>>to provide successfull execution of the
    >>>program.
    >>>
    >>>Now the checking in general is no
    >>>problem, but iīm uneasy about which
    >>>design approach to use...
    >>>
    >>>Until now i usually used an launcher
    >>>class that passes the command line args
    >>>to a "validating" module ( class ) that
    >>>also sets the class fields if the args
    >>>were correct.
    >>>I used to set the class fields in the
    >>>constructor of the "validating" class
    >>>and a lot more... that is i do a lot of
    >>>preparation/work in the constructor...
    >>>now i ask myself is that really a good
    >>>way to go or are there better/more
    >>>efficient ways...
    >>>
    >>>Thanks for any advice
    >>>
    >>>Volker
    >>>

    >>
    >>

    >



  5. #5
    Volker Held Guest

    Re: Command line parameter checking?

    Jeez Per,

    you just screwed my day!
    Havenīt though of a possible DOS/Brute
    attack... though it wonīt be a problem
    with this application - the next iīm
    going to write is a GUI client
    software... thanks for that reminder.

    And thanks... you might havenīt been
    able to solve my command line problem,
    but XML config files and the reminder of
    security issues were great help.

    cheers

    Volker

    Per wrote:
    > Hi again
    > Ohh sorry I misunderstood you.
    > Hmmm, I have no experience with that myself.
    > But if you take the input (username, password....) via the command line,
    > then as I see it you will create an instance of the class each time a user
    > is tryig to connect. And if a user is trying to connect with an illigal password
    > he/she will course manuy objects to be created. I know that the garbage collector
    > will eliminate them, but still.
    > And if one is using an illigal password then as I see it you will not be
    > able to count the number of tryings this could be a problem if a hacker is
    > trying to get access.
    > I do not no if any of this could be a problem for you and as I said I do
    > not have any experience with this my self so I can be of no help - sorry
    >
    > Good luck
    > Per
    >
    >
    > Volker Held <vheld@gwdg.de> wrote:
    >
    >>Hello again Per,
    >>
    >>XML is a great idea, havenīt thought of
    >>using it for configuration files yet,
    >>despite the fact that iīm familiar with
    >>parsing XML.
    >>
    >>But the main problem is that ( i try to
    >>cut it short ) i have to program an
    >>application that will port XML sources
    >>into a relational DB ( MySQL ) and it
    >>has been specified as a command-line tool.
    >>Even if i write the URL to the DB into
    >>an XML config file, i still have the
    >>problem with authorisation.
    >>Use of the program will be restriced to
    >>a few people ( who in detail is yet
    >>unknown and shall be coded flexible ).
    >>Maybe iīm wrong, but in this case i
    >>think the best way to provide different
    >>user access is to get the username and
    >>password by using the command line
    >>params ( String[] args ) - and iīm
    >>looking for an effective way to check
    >>those...
    >>
    >>Per wrote:
    >>
    >>>Maybe it would be an idea to use xml. You could make an xml file with

    >>

    > the
    >
    >>>setup condition and then use an xml parser like the one from ibm (free).
    >>>Some of the validating could then be performed with the xml's dtd (this

    >>

    > validating
    >
    >>>is automatic performed by the ibm parser).
    >>>
    >>>If you make use of xml to hold the setup values it can esaly be changed

    >>

    > if
    >
    >>>you need other values to your application and you will have a great overview
    >>>of the data.
    >>>If you have not worked with xml and dtd it will take some time to understand
    >>>it, but xml and java is working very good together and you will be able

    >>

    > to
    >
    >>>find a lot of java software on the net that can performe the parsing.
    >>>
    >>>To take a quick look at xml see
    >>>http://www.w3schools.com/
    >>>There is no java parser on this link.
    >>>
    >>>
    >>>regards
    >>>Per
    >>>Volker Held <vheld@gwdg.de> wrote:
    >>>
    >>>
    >>>>Hi,
    >>>>
    >>>>does anybody has a "good" example for
    >>>>command line parameter checking?
    >>>>
    >>>>I write a lot of command line tools for
    >>>>java, recently they have become more
    >>>>complex and itīs required to check a
    >>>>number of command line switches in order
    >>>>to provide successfull execution of the
    >>>>program.
    >>>>
    >>>>Now the checking in general is no
    >>>>problem, but iīm uneasy about which
    >>>>design approach to use...
    >>>>
    >>>>Until now i usually used an launcher
    >>>>class that passes the command line args
    >>>>to a "validating" module ( class ) that
    >>>>also sets the class fields if the args
    >>>>were correct.
    >>>>I used to set the class fields in the
    >>>>constructor of the "validating" class
    >>>>and a lot more... that is i do a lot of
    >>>>preparation/work in the constructor...
    >>>>now i ask myself is that really a good
    >>>>way to go or are there better/more
    >>>>efficient ways...
    >>>>
    >>>>Thanks for any advice
    >>>>
    >>>>Volker
    >>>>
    >>>
    >>>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center