Using multiple strings for FINDSTR - is this OK?
Posted: 17 Mar 2021 03:15
Hi Folks -
I have the following logic that I need to check multiple strings. If 1 or more are found from my first check, then need to include other and spool all content to a file. The logic is working but wondering if there is a better way? Also, I'd like to use ORA- as one of my strings but the "-" bombs it, why?
Here is my logic:
Here is my sample file:
I have the following logic that I need to check multiple strings. If 1 or more are found from my first check, then need to include other and spool all content to a file. The logic is working but wondering if there is a better way? Also, I'd like to use ORA- as one of my strings but the "-" bombs it, why?
Here is my logic:
Code: Select all
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
::-- Critical Errors to Check First --::
SET "DM_CRITICAL_CHK="ORA" "Fetch of Driver Member" "Error: 3303" "Error: 3304" "Error: 3333" "Error: 3335" "Error: 3336" "Error: 3337" "does not exist for the specified cube or you do not have access to it" "Outline data store load process finished""
::-- Additional Strings to include if 1 or more Critical Errors found --::
SET "DM_ALL_CHK="FDMEE Process:" "Location :" "Period Name :" "Category Name:" "Rule Name :" !DM_CRITICAL_CHK!"
::-- If one or more Data Management CRITICAL Errors detected, build kickout file --::
FINDSTR /IC:!DM_CRITICAL_CHK! "test.log" && (
FOR %%A IN (!DM_ALL_CHK!) DO (
FOR /F "tokens=* delims=" %%a IN (
'FINDSTR /C:"%%~A" "test.log"'
) DO ECHO %%a>>"out.txt"
)
)
pause
Code: Select all
2021-03-16 22:04:35,737 INFO [AIF]: FDMEE Process: 9, Log Level: 5
2021-03-16 22:04:35,737 INFO [AIF]: Location : Location (Partitionkey:2)
2021-03-16 22:04:35,737 INFO [AIF]: Period Name : Jan-20 (Period Key:1/31/20 12:00 AM)
2021-03-16 22:04:35,737 INFO [AIF]: Category Name: Actual (Category key:1)
2021-03-16 22:04:35,737 INFO [AIF]: Rule Name : Actual_Emp (Rule ID:10)
| Error: 3303 | S23585 | "1380-01","E10","Current","S23585","Actual","FY20","Sep",7088.4 |
| Error: 3303 | S23585 | "1380-03","E10","Current","S23585","Actual","FY20","Sep",9198.81 |
| Error: 3303 | S23585 | "1380-04","E10","Current","S23585","Actual","FY20","Sep",2764.05 |
| Error: 3303 | S23585 | "1999-01","E10","Current","S23585","Actual","FY20","Sep",-19051.26 |
| Error: 3303 | S23585 | "1100-03","E10","Current","S23585","Actual","FY20","Oct",-203.89 |