Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 489
  • Last Modified:

parse txt file for IP and use data to ping

greetings,

i'm tring to make some automated dos scripts to collect some system info
the one ive been stuck on for a week or so is ;

objective parse data.txt file for ip address and gateway and ping each in turn

systems ( windows 9x and 2K )

content of data.txt file;
     IP Address. . . . . . . . . . . . : 192.168.100.32
     Default Gateway . . . . . . . . . : 192.168.100.1


content of script to get data.txt file
ipconfig |..\prog\grep.exe "IP Address"
ipconfig | ..\prog\grep.exe "Default Gateway"


results wanted
1 script gets ip info
2 script pings results
3 script places success msg in results.txt file


thx for any help
alx
0
vextor
Asked:
vextor
  • 2
  • 2
1 Solution
 
CowboyJeeperCommented:
Try this command

for /F "Tokens=2 delims=:" %i in ('type data.txt') do ping %i

Note if you put this in a batch file it will have to look like this

for /F "Tokens=2 delims=:" %%i in ('type data.txt') do ping %%i
0
 
CowboyJeeperCommented:
This will get you a single line put in your results.txt file for both the IP address and the gateway if you like

for /F "Tokens=2 delims=:" %%i in ('type data.txt') do ping %%i -n 1 | FindStr /B "Re" >> results.txt

Its not a success message but rather the exact message that ping gives you.  If the above does not work on a Win9x box use

for /F "Tokens=2 delims=:" %%i in ('type data.txt') do ping %%i -n 1 | Find "Re" >> results.txt

Note: This does have a flaw.  Sometimes even though the network is good a ping may fail.  As this only does one ping you could possibly get a fail message on a good connection, but rarely.
0
 
vextorAuthor Commented:
ok ill try this
0
 
vextorAuthor Commented:
ok ill try this
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now