Computing.Net > Forums > Programming > Batch file input for logevent.exe

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Batch file input for logevent.exe

Reply to Message Icon

Name: sc
Date: May 23, 2007 at 08:52:28 Pacific
OS: Win2k
CPU/Ram: Xeon/4Gb
Product: SuperMicro
Comment:

Hello,

I want to run a batch file every couple of hours, that will take the input from a text file and put it into a field in a command I want to run.

This is the command I want to run in the batch file for every line in a txt file:

logevent -r "TEST" -e "123" "sample message for event"

The line that says "sample message for event", I want to replace that for each line in this txt file example:

2007-03-02 15:26:15 WARNING Intrusion (Bad) failed
2007-03-02 15:26:15 WARNING Power (Bad) failed
2007-03-06 19:01:27 WARNING Intrusion (Bad) failed
2007-03-06 19:01:27 WARNING Power (Bad) failed

So it would turn out like this example:

logevent -r "TEST" -e "123" "2007-03-06 19:01:27 WARNING Power (Bad) failed"

Since I am doing it every couple hours, there will me potentially multiple entries.

How can I get these txt file lines in the batch file command, entered as seperate lines?

Then I planned to use task scheduler to fire it off every couple hours.




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 23, 2007 at 09:14:04 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (my.txt) do (
echo logevent -r "TEST" -e "123" "%%a"
)



=====================================
If at first you don't succeed, you're about average.

M2



0
Reply to Message Icon

Related Posts

See More


Parsing CSV in a batch count in batch



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file input for logevent.exe

Batch file waits for Notepad www.computing.net/answers/programming/batch-file-waits-for-notepad/13205.html

Batch file nested FOR loops help www.computing.net/answers/programming/batch-file-nested-for-loops-help/15196.html

Batch file to check for .exe file www.computing.net/answers/programming/batch-file-to-check-for-exe-file/16163.html