Using configuration files

Many of the utilities provided with SQL Anywhere allow you to store command-line options in a configuration file. If you use an extensive set of options, you may find it useful to store them in a configuration file.

The @data option allows you to specify environment variables and configuration files on the command line. To specify a configuration file, replace data with the path and name of the configuration file. If both an environment variable and configuration file exist with the same name, the environment variable is used.

Configuration files can contain line breaks, and can contain any set of options, including the @data option. You can use the number sign (#) to designate lines as comments. The ampersand (&) character appearing by itself at the end of a line indicates that the previous token is continued on the next line. For example, the following configuration file might be used to start a mirroring server:

-n server1 
-o server1.conslog 
-gd all
-su sql
-hs 
-x tcpip(port=2638;dobroadcast=no) 
-xf server1.state 
asatest.db 
-sn asatest 
-xp partner=(eng=server2;links=tcpip(port=2637;timeout=1)); &
    arbiter=(eng=arbiter;links=tcpip(port=2639;timeout=1)); &
    mode=sync; &
    auth=abc

The @data parameter can occur at any point in the command line, and parameters contained in the file are inserted at that point. You can use @data multiple times on one command line to specify multiple configuration files.

Utilities read the command line by expanding the specified configuration files and reading the entire command line from left to right. If you specify options that are overridden by other options in the command line, the option closer to the end of the line wins. In some cases, conflicting options result in an error.

Note

The Start Server in Background utility (dbspawn) does not expand configuration files specified by the @data option.

If you want to protect passwords or other information in the configuration file, you can use the File Hiding utility to obfuscate the contents of the configuration file.

For more information about obfuscating the contents of a configuration file, see File Hiding utility (dbfhide).

Example

The following configuration file holds a set of options for the Validation utility (dbvalid):

#Connect to the sample database as the user DBA with password sql
-c "UID=DBA;PWD=sql;DBF=samples-dir\demo.db"
#Perform an express check on each table
-fx
#Log output messages to the specified file
-o "c:\validationlog.txt

For information about samples-dir, see Samples directory.

If this configuration file is saved as c:\config.txt, it can be used in a command as follows:

dbvalid @c:\config.txt

Using conditional parsing in configuration files