Log Monitor

Log Monitor is a program for monitoring of changes of files and directories, capable to fulfil a number of actions at reaching the given conditions. Main purpose of the program is to automate the routine operations based on files exchange and also to watch a state of processes, being based on their file activity.

  • Section "References" is intended for detailed learning of the program features and contains the description of actions arguments, various formats, etc.


References

Section "References" is intended for detailed learning of features of the program and contains the information about:

  • arguments of actions (variables);
  • formats of date/time variables;
  • the format of masks (templates).

The installation includes the console version which can be installed as native service under Windows NT/2000.


Argument Variables

The files which are appropriate to monitoring conditions, form the list of files and are transferred to actions. Actions have access to the files information via customized arguments. The arguments are replaced with real values (a filename, a size, time etc.) before actions execution.

Syntax of variables:

%<Name>[="specifiers"]

The percent character is followed by the variable name. The name of argument variable is case-insensitive. Further, the optional format of variable follows after the equal sign. The format string is enclosed in double quotes ("). If the format string contains a double quote or a back slash then they must be preceded with back slash (\), for example:

%File="D\\path\"string\"" (the string D\path"string" will be processed)

Arguments can be recursively nested. It means, that an argument can be specified within the modifier of other argument. The depth of recursion is not limited. If the included argument contains own modifier then it is not necessary to escape quotes around the modifier. Examples of recursive variables:

%Changed="copy %File="N.E" c:\\temp"
%Substring="1,8,%Name"
%Include="%Substring="1,8,%File="N"".txt"

The following arguments are available:

%File

Specifies the full filename. The following modifiers are possible:

  • D - drive letter (including colon, e.g. C:);
  • P - path of the file, without a drive, without a name, with the leading back slash (except of root directory), but without the trailing back slash (\);
  • N - file name (without point);
  • E - file extension (without point);
  • S:n - a part of file path, beginning from the level n from the root directory, for example S:3. It includes the leading back slash, except cases when the file is located on root or n exceeds a real level of directories depth. Let the file is 'C:\DIR1\DIR2\DIR3\FILE.TXT', then %File="S:2" will return '\DIR2\DIR3'.
  • R - the instruction to substitute all back slash characters (\) to forward slashes (/) within resulting string;
  • 'x' or "x" - any character enclosed in single or double quotes is not interpreted.

Variable without the format string corresponds to the full path of the file. The full path can be also specified as

%File="DP\\N.E" or %File="DS:1\\N.E"

%Name

Specifies the name of a file with extension. Modifiers are absent. The argument %File="N.E" is analogue of this variable.

%Path

Specifies the file path without the trailing back slash (\). Modifiers are absent. The argument %File="DP" is analogue of this variable.

%Time

Specifies the file modification time. Modifiers set the format of date/time representation. Read in details about the date/time format.

%Size

Specifies the file size. Modifiers can be set as

%Size="<units><separator>"

The character <units> sets dimension of number and can accept values:

  • B - Bytes;
  • K - KBytes;
  • M - MBytes;
  • G - Gbytes.

The character <separator> sets a separator of groups of three digits, for example:

%Size="K," KB
(for the file size of 1300140 bytes it will be output 1,269 KB)

%Added

The format of argument specifies the text which should be substituted if the file was added:

%Added="File has been added!"

%Changed

The format of argument specifies the text which should be substituted if the file was changed:

%Changed="File has been changed!"

%Deleted

The format of argument specifies the text which should be substituted if the file was deleted:

%Deleted="File has been just deleted!"

%SysDate

Specifies the current system time. Modifiers set the format of date/time representation. Read in details about the date/time format.

%RunTime

Specifies starting time of actions execution after check-up of conditions. Starting time can differ from system time at execution of long operations. Modifiers set the format of date/time representation. Read in details about the date/time format.

%Environment

Specifies the environment variable included by its name. The name of a variable is set by the modifier (required parameter):

%Environment="temp"\tmp.txt

%Include

This argument specifies to include contents of a text file. The argument can be used for inclusion of filter masks from the file (one mask per line). The filename is set by the modifier (required parameter):

%Include="c:\\masks.txt"

%Substring

The argument is intended for getting a substring. The modifier sets a position of a substring (beginning from 1) and number of characters as

%Substring="position,length,string"

The argument can be used with recursive variables, for example, for obtaining a part of a filename:

%Substring="1,5,%File="N"" (first 5 characters of the filename)

%Chr

Specifies the arbitrary character which ASCII code is given by the decimal number:

%Chr="10" (new line)
%Chr="9" (tabulator)

%%

This is a pseudo-argument to specify the percent character (%).

%(
%)

Specifies special arguments to indicate a cycle through the list of files. For example, if it is obtained three files as a result of conditions check-up (file1, file2, file3), then applying of arguments

%SysDate="dd.mm.yyyy": %(%File; %)

will result in:

20.12.2000: file1; file2; file3;

Arguments of cycle cannot be used when file-by-file processing takes place:

  • in the action "Create files list", if option "Enable usage of cycle variables" is not specified;
  • in the action "Execute program" with option "Single file argument placement" enabled;
  • in the action "File operations" with option "File by file argument placement" enabled.


Format of Date/Time Variables

This page describes date and time format specifiers for %Time, %RunTime and %SysDate variables , e.g. %SysDate="dd.mm.yyyy".

Specifier | Displays
c | Displays the date using the format given by the 'Short Date Format' regional setting, followed by the time using the format given by the 'Long Time Format' regional setting.
d | Displays the day as a number without a leading zero (1-31).
dd | Displays the day as a number with a leading zero (01-31).
ddd | Displays the day as an abbreviation (Sun-Sat) using the strings given by the 'Short Day Names' regional setting.
dddd | Displays the day as a full name (Sunday-Saturday) using the strings given by the 'Long Day Names' regional setting.
ddddd | Displays the date using the format given by the 'Short Date Format' regional setting.
dddddd | Displays the date using the format given by the 'Long Date Format' regional setting.
m | Displays the month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
mm | Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
mmm | Displays the month as an abbreviation (Jan-Dec) using the strings given by the 'Short Month Names' regional setting.
mmmm | Displays the month as a full name (January-December) using the strings given by the 'Long Month Names' regional setting.
yy | Displays the year as a two-digit number (00-99).
yyyy | Displays the year as a four-digit number (0000-9999).
h | Displays the hour without a leading zero (0-23).
hh | Displays the hour with a leading zero (00-23).
n | Displays the minute without a leading zero (0-59).
nn | Displays the minute with a leading zero (00-59).
s | Displays the second without a leading zero (0-59).
ss | Displays the second with a leading zero (00-59).
t | Displays the time using the format given by the 'Short Time Format' regional setting.
tt | Displays the time using the format given by the 'Long Time Format' regional setting.
am/pm | Uses the 12-hour clock for the preceding h or hh specifier, and displays 'am' for any hour before noon, and 'pm' for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
a/p | Uses the 12-hour clock for the preceding h or hh specifier, and displays 'a' for any hour before noon, and 'p' for any hour after noon. The a/p specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
ampm | Uses the 12-hour clock for the preceding h or hh specifier, and displays the contents of the 'Time AM String' regional setting for any hour before noon, and the contents of the 'Time PM String' regional setting for any hour after noon.
/ | Displays the date separator character given by the 'Date Separator' regional setting.
: | Displays the time separator character given by the 'Time Separator' regional setting.
'xx'/"xx" | Characters enclosed in single or double quotes are displayed as is, and do not affect formatting. Note: double quotes within format string should be replaced with \".

If the string given by the format parameter is empty, the date/time value is formatted as if a c format specifier had been given.


File masks (templates)

Masks are used at customization of file filters and in the "Terminate program" action. The mask compares to input string, in result the string can match the given mask or not.

A valid mask consists of literal characters, sets, and wildcards.

Each literal character must match a single character in the string. The comparison to literal characters is case-insensitive.

Each set begins with an opening bracket ([) and ends with a closing bracket (]). Between the brackets are the elements of the set. Each element is a literal character or a range. Ranges are specified by an initial value, a dash (-), and a final value. Do not use spaces or commas to separate the elements of the set. A set must match a single character in the string. The character matches the set if it is the same as one of the literal characters in the set, or if it is in one of the ranges in the set. A character is in a range if it matches the initial value, the final value, or falls between the two values. All comparisons are case-insensitive. If the first character after the opening bracket of a set is an exclamation point (!), then the set matches any character that is not in the set.

Wildcards are asterisks (*) or question marks (?). An asterisk matches any number of characters. A question mark matches a single arbitrary character.

Usage of masks slightly differs from MS DOS file masks. Since symbol-by-symbol comparison is performing, the mask "*.*" means the string necessarily containing the character of a point. It means that a file without extension will not match the mask "*.*" unlike in DOS. The most common mask is "*".

Examples of masks:

*.txt (string ending with '.txt')
[a-ckl]_doc* (strings beginning with 'a_doc', 'b_doc', 'c_doc', 'k_doc', 'l_doc')
[!ab][!cd]_ef_[g-m]_?? (strings like 'cb_ef_h_12', but not beginning with 'ac', 'ad', 'bc', 'bd')


Console Version

The installation includes the console version of Log Monitor - logmcon.exe. It is a full-functional version, saying about monitoring and actions. The console version does not contain the interface for customization of monitoring processes, it executes already customized file. Accordingly, it is recommended to configure tasks via the GUI version.

The console version consumes less RAM because there is no graphic interface and configuration module.

The console version can be installed as Windows NT/2000 service (see command line parameters).

Command line parameters

>logmcon.exe [config file]

Specifies to load the indicated configuration file and to start monitoring. If the parameter is not set, then 'default.mon' file will be opened. The file is located in the same directory as the program. If it is not possible to open the configuration file then the program terminates with error message.

>logmcon.exe /install

Specifies to install Windows NT/2000 service to a local computer. The service will be installed with a name LogMonSvc (the service is accessible also via name "Log Monitor"). The service's startup type is "Manual" by default, i.e. the service will not be started automatically at system startup. You can change the startup type in the Services control panel.

>logmcon.exe /remove

Specifies to remove the installed service from a local computer. This command only deletes the service entry from service control manager database, all files are left intact.

>logmcon.exe /start [\\computer] [config file]

The command allows to start the service on the indicated computer and to load the specified file. If computer is not specified, the service will be started on a local computer. If configuration file is not specified then default.mon, which is located in the program directory, will be opened. If the service can not open the configuration file then it terminates with an error.

>logmcon.exe /stop [\\computer]

Specifies to stop the service on the stated computer. If computer is not specified, the service will be stopped on a local computer.

>logmcon.exe /?

The screen with hints on command line parameters is shown.

Service's features and limitations

  1. If the service can not load the configuration file at start, it terminates with the error code 3000.
  2. The service handles the "Pause" command (it can be submitted from the services applet in the Control Panel). The command is similar to the "Stop all processes" command in the GUI version . The "Start" command, submitted after a pause, restores monitoring from a stop moment.
  3. If it is necessary to access network resources then the service should be started under an user account which has access to network resources, instead of the LocalSystem account.
  4. If the "Terminate program" action is used then it is necessary to specify "Allow service to interact with desktop" option in the service properties because applications are identified by titles of windows opened within a working environment of the user.
  5. When "Popup Window" action is used, it is recommended to turn on the option "Enable NT service notification". This mode allows to see a message box even if the user is not logged in interactively into the system. Otherwise, specify "Allow service to interact with desktop" option in the service properties to allow current user to see message boxes.