Environment variables

What they're for

You can use environment variables to

  • Override some of the settings in FreeTDS's configuration file.

  • Advertise the location of the FreeTDS libraries to programs that want them.

  • Control how logging is done.

This section covers the first two items. For information about environment variables that control logging, see Logging

In a typical system, no environment variables need be used. They're sometimes handy for testing, for instance setting TDSVER to check if a connection problem is due to using the wrong protocol version. And they have other uses, described below. But they're just knobs, so don't feel you have to turn every one, unless you're the sort that likes turning knobs.

Environment Variables

FREETDS

may be used to specify the name and location of the freetds.conf file. In prior versions of FreeTDS this variable was known as FREETDSCONF.

TDSVER

governs the version of the TDS protocol used to connect to your server. For a given server, FreeTDS inspects four sources in the following order to determine which TDS protocol version to use, using the first one it finds.

  1. The value specified in TDSVER

  2. A freetds.conf file entry (see below)

  3. The interfaces file entry (see below)

  4. The --with-tdsver option passed to configure

TDSPORT

specifies a TCP port number at which the servername is listening. It overrides the default port (1433 for TDS 4.2/7.0/7.1/7.2/7.3/7.4, 4000 for TDS 5.0) as well as any port specified in the freetds.conf file.

SYBASE

points to the FreeTDS run-time directory. Use of this variable originated with Sybase (the company), and many programs still rely on SYBASE to discover the location of the SYBASE libraries.

The primary use of SYBASE is to advertise the location of the FreeTDS libraries. A secondary use is to point to the location of the interfaces file (if used, see the Appendix), which some programs examine directly.

TDSQUERY , DSQUERY

provides a server name to connect to if none is specified by the application. DSQUERY is the historical Sybase name for this variable.

TDSHOST

overrides the host specified in the freetds.conf.

Setting environment variables

Of course, each shell is a little different. In the Bourne shell and variants such as ksh and bash, to set SYBASE and TDSVER do:

	$ export SYBASE=/usr/local/freetds  # (or your favorite directory)
	$ export TDSVER=7.4

In csh:

	$ setenv SYBASE /usr/local/freetds
	$ setenv TDSVER 7.4

Checking your work

When you're done, you should see something very like this:

	$ ls $SYBASE
	etc include interfaces lib