A PING Batch File

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.    
ktancl88Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leegclystvaleCommented:
@echo off
ping 10.4.6.7
ktancl88Author Commented:
Hi,
it didn't work.
I name it as ping.bat but when i double click on it. It show a blank screen.
leegclystvaleCommented:
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
Check Out How Miercom Evaluates Wi-Fi Security!

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom on how WatchGuard's Wi-Fi security stacks up against the competition plus a LIVE demo!

leegclystvaleCommented:
Where are you running it from? What path?
ktancl88Author Commented:
No good, it show me a blank screen after i double click on the bat file
ktancl88Author Commented:
start > run > cmd
i my place my ping.bat in c:\
leegclystvaleCommented:
try it on the desktop.
Do you have admin rights?

ping.doc
Aaron StreetTechnical Infrastructure Architecture and Global Network ManagerCommented:
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

Aaron StreetTechnical Infrastructure Architecture and Global Network ManagerCommented:
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.
ktancl88Author Commented:
Hi, where would the results.txt placed ?
Aaron StreetTechnical Infrastructure Architecture and Global Network ManagerCommented:
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
Aaron StreetTechnical Infrastructure Architecture and Global Network ManagerCommented:
or any other path you have rights to use.

(Dam i wish you could edit posts after you made them)
ktancl88Author Commented:
nope, is not working, can't locate result.txt
Aaron StreetTechnical Infrastructure Architecture and Global Network ManagerCommented:
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

leegclystvaleCommented:
Try echo >>c:\results.txt
Aaron StreetTechnical Infrastructure Architecture and Global Network ManagerCommented:
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

Aaron StreetTechnical Infrastructure Architecture and Global Network ManagerCommented:
rename this file from working.txt to working.bat
working.txt
Rob WilliamsCommented:
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/
Rob WilliamsCommented:
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
Aaron StreetTechnical Infrastructure Architecture and Global Network ManagerCommented:
http://www.tools4ever.com/products/free/freeping/

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Network Management

From novice to tech pro — start learning today.