?
Solved

ping and output a list of ip's

Posted on 2014-08-15
5
Medium Priority
?
743 Views
Last Modified: 2014-08-22
I need something fairly simple, I just need to ping a list of computers on my text file (printers.txt) with a -a argument to resolve the hostname. then output that to a simple text file, output.txt

I have tried the following but the result was that I had 4k instances of cmd.exe in my processes.

@echo off

type nul>pass.txt

type nul>fail.txt

for /f %%a in (printers.txt) do call :ping %%a

goto :EOF

:ping

echo testing %1

ping %1|find /i "TTL=">nul

if %errorlevel%==0 echo pass&echo %1>>pass.txt

if %errorlevel%==1 echo FAIL&echo %1>>fail.txt


again, I ended up with about 4k instances of cmd.exe and find.exe (a grep instance of some sort).

I'm not real smart but I would like some assistance on this. I just want a very simple ping -a and output to a text or.csv file.
0
Comment
Question by:AlfonsoPina
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
zalazar earned 2000 total points
ID: 40264361
It's not so easy to accomplish this with a batch file.
I have created a Visual Basic script for this task.

Unpack PingComputer-1.zip and copy the files to a new directory.

Place the IP-addresses from "printers.txt" in "PingComputer.txt", one IP-address per line.
Run "PingComputer.cmd" which will execute "PingComputer.vbs" with cscript.exe
The output will be written to "PingComputer_Output.csv" in the same directory as the script.
PingComputer-1.zip
0
 

Author Closing Comment

by:AlfonsoPina
ID: 40267938
Thanks, I'm not very good at coding, a little c++ and java but no vbs at all. This solution helped me, I will probably use it all week long. Thanks again.
0
 
LVL 12

Expert Comment

by:zalazar
ID: 40268183
You are very welcome and good to know that it's working fine. Thanks for the grade.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40269145
I suspect your batch file you might have called PING.cmd or PING.bat perhaps and therefore it looped and re-ran itself?

I know you have an answer, but for anyone wanting a batch solution too I have a few here of mine, a variation of the one I use a lot when no other methods are available to monitor certain kit is reachable and email me if not...

http://scripts.dragon-it.co.uk/links/batch-monitor-ping-email
http://scripts.dragon-it.co.uk/links/batch-ping-check-hosts
http://scripts.dragon-it.co.uk/links/batch-ping-list-of-hosts

Steve
0
 

Author Comment

by:AlfonsoPina
ID: 40278859
thanks Steve, I hadn't thought of that but i suspect you are correct. I will take a look at my batch file and see if I can put a restriction on it somehow.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Windows Server 2003 introduced persistent Volume Shadow Copies and made 2003 a must-do upgrade.  Since then, it's been a must-implement feature for all servers doing any kind of file sharing.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

862 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