How to get the pathname of the current executable?

Leslie Mikesell les at chinet.chi.il.us
Fri Feb 9 08:08:29 AEST 1990


In article <1610.25d028a3 at wums.wustl.edu> bethge at wums.wustl.edu writes:

>I like to write programs that users can use without having  to  know
>details  of  their  inner  workings.   Suppose  a program needs some
>standard data which the user doesn't need to be concerned with,  and
>which  for  various reasons needs to be read from a file rather than
>compiled in.  The question is, how does the program find the file?

The normal unix choices would be:
 1) connect the file to one of the stdio streams before execution.
    This has the advantage of allowing pipes to work and can be
    hidden from the user by a shell wrapper.
 2) have a "start-up" configuration file in a standard place that
    set all the other options.  You might also look for a second
    set up file in the user's HOME directory.
 3) (my favorite) Put all the options on the command line with
    reasonable defaults compiled in.  Then if the desired options
    become clumsy to type in, just add a shell wrapper for the
    common variations.  As long as you are calling getopt() you
    might as well anticipate every option anyone might want.

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.questions mailing list