Changing the current working directory for the SAS® Workspace Server


When using a SAS Workspace Server session through a SAS client such as SAS® Enterprise Guide®, you might receive an error if you attempt to write a file without providing the complete file path. The following code demonstrates the problem:

   data _null_; 
   file "text.txt";  
   put "This is a test"; 
   run;

The SAS log contains the following error:

   15         data _null_;
   16         file "test.txt" ;
   17         put "This is a test";
   18         run;

   ERROR: Insufficient authorization to access /sasconfig/Lev1/SASApp/test.txt.
   NOTE: The SAS System stopped processing this step because of errors.
   NOTE: DATA statement used (Total process time):
         real time           0.00 seconds
         cpu time            0.00 seconds 

Assuming the path above, a script whose complete path is /sasconfig/Lev1/SASApp/WorkspaceServer/WorkspaceServer.sh is used to launch the Workspace Server session. That script, in turn, sources the script /sasconfig/Lev1/SASApp/appservercontext_env.sh, which contains a UNIX cd command that changes the current working directory to /sasconfig/Lev1/SASApp.

The problem is that users normally do not have permission to create files in that directory. As a result, an error is written to the SAS log file.

To circumvent, modify the script /sasconfig/Lev1/SASApp/WorkspaceServer/WorkspaceServer_usermods.sh to include a UNIX cd command that changes the current working directory to a different location. For example, modify the script to include the following lines:

   USERMODS_OPTIONS=
   cd $HOME  

This places users in their defined UNIX $HOME directories, but any valid path where the users have Write access can be used.

Note: Do not remove the cd command from /sasconfig/Lev1/SASApp/appservercontext_env.sh.

There are some relative path references in the scripts used to launch the SAS server processes that rely on setting the current directory in this script. However, by the time the /sasconfig/Lev1/SASApp/WorkspaceServer/WorkspaceServer_usermods.sh script is called, there is no longer a need to maintain the configuration directory as the current working directory.