Page 1 of 1
find/search specified word "Dostips" in last line
Posted: 29 Jun 2011 11:21
by mohdfraz
Hi,
I need a Dos batch file command to, find/search specified word "Dostips" in last line of specified c:\a.txt file and if found run 1.txt file if not then go to loop and keep monitoring file.
Thanks
Re: find/search specified word "Dostips" in last line
Posted: 29 Jun 2011 12:01
by !k
Code: Select all
@echo off &setlocal enableextensions
:loop
for /f "tokens=1,* delims=]" %%k in ('find /n /v "" a.txt') do (
echo "%%l"|findstr /c:"Dostips" >nul &&set find=Yes||set find=)
if not "%find%"=="Yes" (ping -n 2 127.0.0.1 >nul &goto :loop)
start 1.txt
Re: find/search specified word "Dostips" in last line
Posted: 29 Jun 2011 12:19
by mohdfraz
!K
Wahoo,,, U r an expert. It worked great.
Please One more thing to make sure word is not missed, If it is possible that instead of only looking last line, If it can look for word "Dostips" in Last 10 lines of A.txt file? if match found run 1.txt other wise goto Loop and keep monitoring the file.
Thanks in Advance
Re: find/search specified word "Dostips" in last line
Posted: 29 Jun 2011 12:57
by !k
Code: Select all
@echo off &setlocal enableextensions
set "log=c:\a.txt"
:loop
ping -n 2 127.0.0.1 >nul
for /f "delims=[]" %%l in ('find /n /v "" "%log%"') do set /a line=%%l-10
if %line% LSS 0 set /a line=0
more +%line% "%log%" |findstr /c:"Dostips" >nul &&start 1.txt ||goto :loop
Re: find/search specified word "Dostips" in last line
Posted: 29 Jun 2011 14:38
by mohdfraz
Wahoo, Impressive. You r the Star!!!
I searched the net but no luck!!
I gave this question on other forums but no reply.
But solved it in minutes.
Thank you very very much. God bless u all the time.