0 Replies - 2913 Views - Last Post: 16 May 2012 - 07:40 PM Rate Topic: ***** 1 Votes

#1 kienkiatteo  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 16-May 12

Batch file could not copy the specific line

Posted 16 May 2012 - 07:40 PM

Hi,
I tried this code in the batch file but it could not work.
I wanted to take the first line from the DefaultGateway.txt and replace the 5th line ip address in NewFile.txt.


Batch File Codes :
ipconfig /all | findstr Gateway > "C:\Program Files (x86)\""Wireless Guard\""DefaultGateway.txt"

SetLocal EnableDelayedExpansion
type nul > NewFile.txt
set "Default" =Start Line of Paragraph
set "254"=End Line which is not Included
set Flag=0
for /f "tokens=* delims=" %%a in ('type DefaultGateway.txt') do (
 if /i "%StartText%" EQU "%%a" (set Flag=1) 
if /i "%EndText%" EQU "%%a" (set Flag=0) 
if !Flag! EQU 1 echo %%a >> NewFile.txt
)


DefaultGateway.txt :
   Default Gateway . . . . . . . . . : 172.20.128.254
   Default Gateway . . . . . . . . . : 
   Default Gateway . . . . . . . . . : 



NewFile.txt :
remarks:This document is for Linksys for version v4.30.5, the auto sensing part.

"C:\Program Files (x86)\Wireless Guard\wget" --http-user= --http-password=admin 

http://192.168.1.1/WClientMACList.htm


REM del WClientMACList.txt
REM del arp.txt
REM del Intruder1.txt

copy WClientMACList.htm WClientMACList.txt

del WClientMACList.htm

REM del WL_ActiveTable.asp


REM do ping for 20 seconds
REM ping -n localhos



Is This A Good Question/Topic? 0
  • +

Page 1 of 1