?
Solved

A PING Batch File

Posted on 2008-11-14
20
Medium Priority
?
1,856 Views
Last Modified: 2012-05-05
Hi,
I want to create a bat file that I can ping to several servers.
I have tried
%echo off%
PING 10.204.1.35    but seem like doesn't work.    
0
Comment
Question by:ktancl88
  • 8
  • 5
  • 5
  • +1
20 Comments
 
LVL 13

Expert Comment

by:leegclystvale
ID: 22958343
@echo off
ping 10.4.6.7
0
 

Author Comment

by:ktancl88
ID: 22958405
Hi,
it didn't work.
I name it as ping.bat but when i double click on it. It show a blank screen.
0
 
LVL 13

Expert Comment

by:leegclystvale
ID: 22958406
for multiple servers just add another line
@echo off
ping www.yahoo.com
ping www.microsoft.com
ping www.google.com
you won't get a reply from Microsoft
0
2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

 
LVL 13

Expert Comment

by:leegclystvale
ID: 22958410
Where are you running it from? What path?
0
 

Author Comment

by:ktancl88
ID: 22958420
No good, it show me a blank screen after i double click on the bat file
0
 

Author Comment

by:ktancl88
ID: 22958434
start > run > cmd
i my place my ping.bat in c:\
0
 
LVL 13

Expert Comment

by:leegclystvale
ID: 22958447
try it on the desktop.
Do you have admin rights?

ping.doc
0
 
LVL 16

Expert Comment

by:Aaron Street
ID: 22958530
ok I do have a ping batch file that reads from a file and pings all name/address and give you a basi report.

:: multiIP.bat
@echo off

for /f "tokens=*" %%I in (names.txt) do call :pinger %%I
goto :eof

:pinger
     
Ping -n 2 -w 100 %1  >> results.txt
echo %1            %TIME%  >> results.txt    
echo *************************************************** >> results.txt
:: DONE


make a file in the same folder called names.txt and add one server address per line

it will create a result file (not very nice formated I give you) with the results

however I would serch for freeping by tools forever as this is a great tool where you can add the servers you want and it will give you a running report on how they reply

or look up angryip scanner if you want to scan a range of ip's by pinging

0
 
LVL 16

Expert Comment

by:Aaron Street
ID: 22958547
PS you get a black screen because you have run the echo off command..

try replacing it with echo on and you will see the results.
0
 

Author Comment

by:ktancl88
ID: 22958836
Hi, where would the results.txt placed ?
0
 
LVL 16

Expert Comment

by:Aaron Street
ID: 22958862
in the same folder as you run the batch file from

if you want simple change the line in the file to
echo *************************************************** >> c:\results.txt
0
 
LVL 16

Expert Comment

by:Aaron Street
ID: 22958869
or any other path you have rights to use.

(Dam i wish you could edit posts after you made them)
0
 

Author Comment

by:ktancl88
ID: 22958938
nope, is not working, can't locate result.txt
0
 
LVL 16

Expert Comment

by:Aaron Street
ID: 22958965
ok well it works perfectly on my PC.

click start,
run cmd to get a command prompt

drag and drop the batch file in to the window  (short cut to enter in teh path to a batch file)

hit return and see what the error message says.

I would also suggest changing the echo off to read echo on

0
 
LVL 13

Expert Comment

by:leegclystvale
ID: 22958966
Try echo >>c:\results.txt
0
 
LVL 16

Expert Comment

by:Aaron Street
ID: 22959012
for a bit of info,

echo >> "file name"  will append to a file (or create it if it is not currently there and apend to it)
echo > "file name" will over write the data in a file.

now the out put should look some thing like bellow. (as you can see bad formatting)

what do you need this batch file for?
I wrote it ages ago and never bothered to tidy it up.


Ping request could not find host PRI0313. Please check the name and try again.
 
PRI0313		10:58:18.55      
*************************************************** 
Ping request could not find host PRI0570. Please check the name and try again.
 
PRI0570		10:58:20.84      
*************************************************** 
Ping request could not find host PRI0575. Please check the name and try again.
 
PRI0575		10:58:23.13      
*************************************************** 
 
 
Pinging PRI0595.abc.acb.com [192.168.1.1] with 32 bytes of data:
 
 
 
Reply from 148.253.117.98: bytes=32 time<1ms TTL=64
 
Reply from 148.253.117.98: bytes=32 time<1ms TTL=64
 
 
 
Ping statistics for 148.253.117.98:
 
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
 
Approximate round trip times in milli-seconds:
 
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
 
PRI0595		10:58:24.15      
*************************************************** 
Ping request could not find host PRI0600. Please check the name and try again.
 
PRI0600		10:58:26.44      
*************************************************** 
Ping request could not find host PRI0610. Please check the name and try again.
 
PRI0610		10:58:28.73      
*************************************************** 

Open in new window

0
 
LVL 16

Expert Comment

by:Aaron Street
ID: 22959031
rename this file from working.txt to working.bat
working.txt
0
 
LVL 78

Assisted Solution

by:Rob Williams
Rob Williams earned 300 total points
ID: 22960497
If you want to monitor connectivity to different machines, consider using IPMonitor (now netgong). I had written a batch file to do similar to above (I can post) but didn't like that many pings running frequently. IPMonitor allows you to send 1 ping every x minutes. It then logs connectivity, can be configured to notify of failed connections after x failures, and keeps a nice html log.
http://netgong.tsarfin.com/
0
 
LVL 78

Expert Comment

by:Rob Williams
ID: 22960533
From an earlier post of mine, if of some value:

I put the following together. It should test your connection for you (>1/sec), however careful, it is pretty crude. It runs forever until you press Ctrl+C, but it makes no log entries until there is a disconnect. However, if the cable is disconnected for long it will fill the log very quickly. You might want to put some limits on it but I didn't have time right now. To run you need a tiny utility called Alive, as explained in the batch file. Just save with a name like Connect.bat and run by entering Connect <IP address>  e.g.  Connect 123.123.123.123  It will create a log file in the same folder named IPlog.txt with basic diagnostics as to why the disconnect.
Hope it is of some help.


Echo Off
Cls
Set TestIP=%1%
:: Download a little app called Alive from  http://wettberg.home.texas.net/alive.htm
:: Extract the files to a directory with this batch file and run using 'FileName <IP address>'
::  (see the Alive.txt file for an explanation of the app)
Echo.
Echo Note: This batch file will run FOREVER and if the cable is disconected for any
Echo  length of time, it will great a very large log very quickly.
Echo.
Echo  Press Ctrl+C  to exit
Pause

If Exist IPLog.txt Del IPLog.txt
Echo IP monitoring started %Date:~0,12% %Time:~0,5% >>IPLog.txt

:NEXT
ALIVE /Timeout=3 %TestIP%
If ErrorLevel 255 GoTo E255
If ErrorLevel 8 GoTo E8
If ErrorLevel 7 GoTo E7
If ErrorLevel 6 GoTo E6
If ErrorLevel 5 GoTo E5
If ErrorLevel 4 GoTo E4
If ErrorLevel 3 GoTo E3
If ErrorLevel 2 GoTo E2
If ErrorLevel 1 GoTo E1
GoTo NEXT
:E1
Echo %Date:~0,12%  %Time:~0,5% Request timed out >>IPLog.txt
GoTo NEXT
:E2
Echo %Date:~0,12%  %Time:~0,5% Destination host unreachable >>IPLog.txt
GoTo NEXT
:E3
Echo %Date:~0,12%  %Time:~0,5% Destination network unreachable >>IPLog.txt
GoTo NEXT
:E4
Echo %Date:~0,12%  %Time:~0,5% Destination protocol unreachable >>IPLog.txt
GoTo NEXT
:E5
Echo %Date:~0,12%  %Time:~0,5% Destination port unreachable >>IPLog.txt
GoTo NEXT
:E6
Echo %Date:~0,12%  %Time:~0,5% Hardware error >>IPLog.txt
GoTo NEXT
:E7
Echo %Date:~0,12%  %Time:~0,5% TTL expired in transit >>IPLog.txt
GoTo NEXT
:E8
Echo %Date:~0,12%  %Time:~0,5% Bad Destination  >>IPLog.txt
GoTo NEXT
:E255
Echo %Date:~0,12%  %Time:~0,5%  Unknown errors  >>IPLog.txt
GoTo NEXT
0
 
LVL 16

Accepted Solution

by:
Aaron Street earned 750 total points
ID: 22960825
http://www.tools4ever.com/products/free/freeping/

is a nice tool for monitering as I mentioned before. have a look at the screen shots
0

Featured Post

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

Question has a verified solution.

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

Quality of Service (QoS) options are nearly endless when it comes to networks today. This article is merely one example of how it can be handled in a hub-n-spoke design using a 3-tier configuration.
In this article, the configuration steps in Zabbix to monitor devices via SNMP will be discussed with some real examples on Cisco Router/Switch, Catalyst Switch, NAS Synology device.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

807 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