About Command Line Automation
Published 06 January 2020
The command-line is installed alongside the Data Masker application, it takes a single parameter that points to a
PARFILE containing the details of the masking job to run:
> [Installation Directory]\DataMaskerCmdLine.exe PARFILE=[path to parameter file]
> "C:\Program Files\Red Gate\Data Masker for SQL Server 7\DataMaskerCmdLine.exe" PARFILE=C:\MaskingSets\SamplePARFILE.txt > "C:\Program Files\Red Gate\Data Masker for Oracle 6\DataMaskerCmdLine.exe" PARFILE="C:\Masking Sets\Sample PARFILE.txt"
The Parameter File
The parameter file can specify the following options:
|Required||The full path of the masking set to be run.|
|Required||The full path to the directory where log files will be placed.|
The full path to the directory containing the datasets. Unless you have created your own directory, the datasets are installed alongside Data Masker in the following locations:
|Required||The full path to the directory where the reports should be exported.|
Add a LOGINSUB line to the file for each controller in the masking set that needs to be changed to point to a different database (or with a different user account).
For more information about login substitution see:
SQL Server Only. Data Masker will replace any instance of these parameter names with their value in any SQL. The xx is a two-digit numeric value. See substitution values for more details.
Oracle Only. Data Masker will replace any instance of these parameter names with their value in any user-specified SQL. The xx is a two-digit numeric value. See substitution values for more details.
DMSSUBVALUExx (SQL Server version) /
DMOSUBVALUExx (Oracle version)
Up to twenty replacement strings can be specified in the parameter file. These runtime substitution values are designed to permit generic SQL statements to be dynamically adjusted at runtime for specific targets during batch operations.
Note: The keywords for these replacement strings are
DMSSUBVALUE19. If the text
%DMSSUBVALUExx% is used in a Command rule or in the Where Clause of a masking rule, the value associated with that keyword will be replaced at runtime before the rule is executed.
For example, if a Command rule included a statement like:
TRUNCATE TABLE %DMSSUBVALUE05%_TEMP;
and the parameter file contained a line stating
DMSSUBVALUE05=TESTUSER then the actual statement that would be executed would be:
TRUNCATE TABLE TESTUSER_TEMP;
TESTUSER would be substituted for the
%DMSSUBVALUE05% text in the SQL statement immediately before the statement was executed.
SQL Server PARFILE
MASKINGSET=C:\Program Files\Red Gate\Data Masker for SQL Server 7\Demo.DMSMaskSet LOGFILEDIR=C:\TEMP\Data Masker\ DATASETSDIR=C:\Program Files\Red Gate\Data Masker for SQL Server 7\DataSets REPORTSDIR=C:\TEMP\Data Masker\ INTERIM_REPORTS=false LOGINSUB=placeholder-login@DEV-DB[DataWarehouse]||DataMasker/SecurePassword@STAGING\SQL2019[DataWarehouseMasked] -- Substitution values DMSSUBVALUE00=DM_INVOICE_LINE_HISTORY DMSSUBVALUE05=DM_INVOICE_LINE_HISTORY
MASKINGSET=C:\Program Files\Red Gate\Data Masker for SQL Oracle 6\Demo.DMSMaskSet LOGFILEDIR=C:\TEMP\Data Masker\ DATASETSDIR=C:\Program Files\Red Gate\Data Masker for SQL Oracle 6\DataSets REPORTSDIR=C:\TEMP\Data Masker\ INTERIM_REPORTS=false --LOGINSUB=DummyLogin@DummyServer[DummyDatabase]||DataMasker/DataMasker@DEMODB[DMTest] --LOGINSUB=XXXLogin@XXXServer[XXXDatabase]||DBSSourceUser/DBSSourceUser@N2KBUILD-PC\N2KTEST1[DBSSource] DMOSUBVALUE00=DM_INVOICE_LINE_HISTORY DMOSUBVALUE05=DM_INVOICE_LINE_HISTORY
The command-line will return an exit code to indicate success or failure; if the run of the masking rules was successful, then this exit code will always be zero. Any non-zero exit code implies that an error occurred while opening the masking set or while running the masking rules. If a non-zero exit code is returned, the log file should always be examined to determine the error that occurred. The defined exit codes are:
|The command-line has successfully run the masking set.|
|An unhandled exception occurred.|
|The masking run failed but no specific error was reported.|
|There was an unexpected error trying to start the logging system.|
|There was an error trying to create the log files, check that the |
|There was an error in parsing the command-line arguments or the PARFILE contents.|
|There was an processing the datasets found in the |
|The masking set specified in the |
|There was an error opening the masking set.|
|There was an error processing the |
|There was an error executing one or more masking rules.|
If an error occurs there will be more detail in the log that is created in the
LOGFILEDIR directory, some information will be written to the console output.
If running from the standard command-line then `echo %errorlevel%` can output the exit code. For example:
C:\Program Files\Red Gate\Data Masker for SQL Server 7>DataMaskerCmdLine.exe PARFILE=C:\workspace\data-masking\DMV6\DMS_TestSets\DebugPARFILE.txt ... C:\Program Files\Red Gate\Data Masker for SQL Server 7>echo %ERRORLEVEL% 200