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

Batch file input for logevent.exe

Reply to Message Icon

Original Message
Name: sc
Date: May 23, 2007 at 08:52:28 Pacific
Subject: Batch file input for logevent.exe
OS: Win2k
CPU/Ram: Xeon/4Gb
Model/Manufacturer: 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.



Report Offensive Message For Removal

Response Number 1
Name: Mechanix2Go
Date: May 23, 2007 at 09:14:04 Pacific
Subject: Batch file input for logevent.exe
Reply: (edit)

@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



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch file input for logevent.exe

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software