Computing.Net > Forums > Disk Operating System > Extract variable, then call batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Extract variable, then call batch

Reply to Message Icon

Name: lbf864
Date: May 13, 2008 at 11:59:09 Pacific
OS: Win2K
CPU/Ram: n/a
Product: IBM
Comment:

I am trying to write a batch file to look into a .txt log file and check for a return code BB3 (BB3 will be the only text in this file).

If BB3 is in the log file, execute bat1.bat.
If BB3 is not in the log file, execute bat2.bat.

I am really stumped. Any help would be appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: DosX
Date: May 14, 2008 at 00:59:16 Pacific
Reply:

-- log.txt --
BB3

-- read.bat --
@ECHO OFF
FIND "BB3" log.txt>nul
IF ERRORLEVEL 1 GOTO NOBB3
IF ERRORLEVEL 0 GOTO BB3

ECHO There was some error.
GOTO exit

:BB3
ECHO Log.txt contains BB3
CALL bat1.bat
GOTO exit

:NOBB3
ECHO Log.txt does not contain BB3
CALL bat2.bat
GOTO exit

:exit


0

Response Number 2
Name: lbf864
Date: May 14, 2008 at 11:20:33 Pacific
Reply:

Thanks DosX...I actually did it this way:

@echo off
SetLocal EnableDelayedExpansion

FOR /F "tokens=1" %%i IN (C:\BB_Log.txt) DO (
IF %%i==BB3 (CALL BB3.bat) ELSE (CALL NOBB3.bat)
)

It works....am I an idiot for using my way?


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Extract variable, then call batch

Is there any ways to declare a variable inside a batch file ?? www.computing.net/answers/dos/is-there-any-ways-to-declare-a-variable-inside-a-batch-file-/3377.html

Accept Variables into a Batch www.computing.net/answers/dos/accept-variables-into-a-batch/322.html

Running variables after a .exe file www.computing.net/answers/dos/running-variables-after-a-exe-file/13737.html