?
Solved

parse txt file for IP and use data to ping

Posted on 2003-03-29
4
Medium Priority
?
482 Views
Last Modified: 2008-02-26
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
Comment
Question by:vextor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:CowboyJeeper
ID: 8233983
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
 
LVL 6

Accepted Solution

by:
CowboyJeeper earned 150 total points
ID: 8234059
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
 

Author Comment

by:vextor
ID: 8234644
ok ill try this
0
 

Author Comment

by:vextor
ID: 8238499
ok ill try this
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question