Why use environment variables with xfServer?

Although you can hard-code server specifications in your program, to keep your xfServer system portable and manageable you must define environment variables and use them in your application’s filename specifications. If you hard-code the entire file specification in your program, and those files move, or if your user doesn’t set up the system exactly as you expect, you will need to change the file specifications and recompile your program.

For example, instead of using a hard-coded method such as this for file access:

open(1,u:i,"filename@server")

We recommend using an environment variable assignment (or logical on OpenVMS), such as this:

open(1,u:i,"env_variable:filename")

The environment variable replaces the server name in your actual code.

The following examples show two ways that you might define the DAT environment variable:

DAT=@server_name

On OpenVMS, this will point to the user’s home directory. (See RSFILPATH for more information about this environment variable.)

DAT=SRV:@server_name

In this case, all users go to the same directory. You must also define the SRV environment variable on the xfServer machine. For instructions on defining environment variables for the xfServer service, refer to the following operating system-specific information:

Let’s say that you’ve defined DAT=SRV:@server, and your application has the statement:

open(1,u:i,"DAT:cusmas")

The DAT:cusmas data request might be translated as shown in figure 1 for a Windows client connected to a UNIX server.      

1. Translating a request from a Windows client to a UNIX server
using an environment variable.