Using Environment Variables

From InterBase
Jump to: navigation, search

Go Up to Programming with the InterBase API


InterBase client applications can use four environment variables to establish program parameters. These variables must be set so that they are available to the application when it is running. For example, setting these variables within a DOS window after Microsoft Windows has been started does not affect any Windows programs, but does affect DOS applications in that window.

The following table summarizes these variables and their uses:

Environment Variables Used by InterBase
Variable Purpose Example

ISC_USER

Specifies a user name for the PC client application.

SET ISC_USER = HERMES

ISC_PASSWORD

Specifies a case-sensitive ­password for the PC client ­application.

SET ISC_PASSWORD = Ichneumon

INTERBASE

If one installsInterBase to a non-default directory, setting the INTERBASE environment variable helps the client application contact the correct server instance running from the same INTERBASE location.

On Windows set the following in your system environment: INTERBASE=C:\Embarcadero\InterBase.

On UNIX set the following in your session environment. Default is either /usr/interbase/ or /opt/interbase/ depending on the UNIX system being used.

INTERBASE=/mydir/interbase

IB_PROTOCOL

Can be set to the name of the InterBase instance that you want to communicate with by default.

If this environment variable is not set, the client applications are expected to provide the instance name of the server to connect to in the database URL syntax.
For example:
connect 'localhost/my_instance:c:\interbase\examples\employee.gdb';

The IB_PROTOCOL is also used when connecting to remote servers. In this case, the instance name mentioned needs to have a TCP socket port number specified in the services file so the remote TCP port number can be connected.

If IB_PROTOCOL is set in the environment as such:

IB_PROTOCOL=my_instance

The ISC_USER and ISC_PASSWORD environment variables are used together to establish a valid user name and password combination to pass to the remote InterBase database server.

Important: Do not use the ISC_PASSWORD environment variable when security is a concern. Anyone with access to a client where an ISC_PASSWORD environment variable is defined in a file such as autoexec.bat can easily view the password.


Setting a Default Database Directory

To connect automatically to a default database directory on a remote server, create the ISC_DATABASE environment variable and set it to the full path specification for the desired database directory, including host and path names.

Note: Host name specification depends upon the server’s operating system and network protocol. The host syntax in the previous example is for a generic UNIX server. For other servers and operating systems, see that system’s reference manuals.


Setting a User Name and Password

To set up a default user name and password for use on a PC client, create two environment variables, ISC_USER, and ­ISC_PASSWORD.

Even if ISC_USER and ISC_PASSWORD are set, a different user name and password may be specified in a DPB used as an argument to isc_attach_database(). A user name or password specified in a database parameter buffer overrides the OS environment variables.

Note: Using environment variables in this manner is not secure, and therefore not recommended.

Advance To: