You can define a Text File Reading and Monitoring (TEXT_MON) job to search a text file on a Windows, UNIX, or i5/OS computer for a text string. For example, you can monitor a log file for an error message after a script executes.
Note: To run these jobs, your system requires CA WA Agent for UNIX, Linux, Windows, or i5/OS.
Required Statements
To define a Text File Reading and Monitoring job, you must specify the following statements:
Optional Statements
You can specify the following optional statements for a Text File Reading and Monitoring job:
Example: Search for a Text String on a Windows System
This example searches for a text string in a text file on a Windows computer. The path to the text file is enclosed in single quotation marks because the path contains a space. The job searches between lines 1 and 20. The job completes successfully if the string is found.
AGENT SYSAGENT TEXTFILE 'c:\Program Files\CA\component.txt' TEXTSTRING 'CreateService failed' EXIST SEARCHRANGE LINE FROM(1) TO(20)
Example: Monitor an i5/OS Text File for a String in the First 20 Lines of the File
This example searches for a text string in the DATA member of a QSYS file object on an i5/OS computer. The job searches the content between lines 1 and 20. The job completes successfully if the string is found.
AGENT I5AGENT TEXTFILE /QSYS.LIB/LIBRARY.LIB/RESULTS.FILE/DATA.MBR TEXTSTRING 'Create file failed' EXIST SEARCHRANGE LINE FROM(1) TO(20)
Example: Monitor a File for a String using a Regular Expression
In this example, the text string contains regular expression pattern matching syntax. The search range is also a regular expression as indicated by the operand REGEX in the SEARCHRANGE statement.
AGENT SYSAGENT
TEXTFILE '/home/cybesp/file.txt'
TEXTSTRING '^\w{4,10}\.' EXIST
SEARCHRANGE REGEX FROM(\A\W\sE)
The regular expression can be interpreted as follows:
To illustrate the last item {4, 10}, consider the following syntax:
TEXTSTRING 'b1{1,3}c'
Evaluating this expression yields the following conditions:
|
Copyright © 2013 CA Technologies.
All rights reserved.
|
|