Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Batch file to ping several servers.

Original Message
Name: Brogan
Date: November 1, 2005 at 17:33:01 Pacific
Subject: Batch file to ping several servers.
OS: WinXP
CPU/Ram: 256 mb
Comment:
I need a sample batch file that will ping several servers and send the results to a log file, with a time stamp as well.

If possible, it would be great if all i had to do was just plug in the IP addresses and move along. Please help me out if you can, i would appreciate it.


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: November 1, 2005 at 20:28:09 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
Try this:

:: multiIP.bat
@echo off

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

:pinger

echo %TIME% >> pingLOG
ping %1 >> pingLOG
:: DONE


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 2
Name: Brogan
Date: November 2, 2005 at 03:58:37 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
Thanks for the help, now another question is do i have to create the log file first, or will it save it to it automatically?


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: November 2, 2005 at 05:01:56 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
It creates / appends the log file.

If you want a fresh log file for each "run" just change the first line to:

@echo off > pingLOG

which wipes the existing pingLOG



If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 4
Name: Brogan
Date: November 2, 2005 at 13:28:25 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
Ok, i copied and pasted the exact batch into notepad and saved it as multiIP.bat. I did substitute an actual IP address for (IPlist). Is that all i have to do? Because it's not working. Please let me know what else may need to be changed.

Thanks


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: November 2, 2005 at 21:35:25 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
Hi,

IPlist is the name of a file containing the IPs to ping.

Try that.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal


Response Number 6
Name: Brogan
Date: November 3, 2005 at 03:26:28 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
ok, and just to be sure, should i keep the parenthesis with IPlist, and also do i need to put the path name with it, or just the IPlist?

Thanks.


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: November 3, 2005 at 04:07:44 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
Hi,

You need the parentheses.

And you need the path to the file if it's not in the current directory.

in (c:\temp\IPlist) do


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 8
Name: Brogan
Date: November 3, 2005 at 18:07:35 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
Ok, i hope this is the last question, cause i hate to keep bothering you, but it's still not working.

This is what i have in my "multiIP.bat" program:

@echo off

for /f "tokens=*" %%I in (C:\Documents and Settings\Ben\Desktop\batch\IPlist.txt) do call

:pinger %%I
goto :eof

:pinger

echo %TIME% >> C:\Documents and Settings\Ben\Desktop\batch\pingLOG.txt
ping %1 >> C:\Documents and Settings\Ben\Desktop\batch\pingLOG.txt
::DONE

I created a folder called "batch" on my desktop to hold these files. Let me know what i need to change, what needs to be added, etc.

Thanks again, you're a big help.


Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: November 3, 2005 at 22:26:17 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
Hi,

Because of the spaces in the path, I beleive you'll need:

("C:\Documents and Settings\Ben\Desktop\batch\IPlist.txt")

The same goes for the other two instances of the path, in the :pinger.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 10
Name: Brogan
Date: November 4, 2005 at 03:27:15 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
Man, i don't understand, it's still not working. What should the ip list have, just the addresses, or should it say ping in front of them, or anything else i'll need?

Also, should i leave the ".txt" with the file names?


Report Offensive Follow Up For Removal

Response Number 11
Name: Mechanix2Go
Date: November 5, 2005 at 00:23:07 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
The list of IPs needs just the numerical IPs, like this:

127.0.0.1
122.22.3.15

In answer to your last question, you can use any legal file name, with or without an extension.

Are you getting errors?

No pingLOG.txt?

Crash?


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 12
Name: Brogan
Date: November 5, 2005 at 07:14:46 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
no pinglog. it flashes the command prompt real quik and that's it.

Report Offensive Follow Up For Removal

Response Number 13
Name: Mechanix2Go
Date: November 5, 2005 at 08:26:58 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
Open a cmd prompt and run it so you can see what it's doing.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 14
Name: Brogan
Date: November 7, 2005 at 12:16:56 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
It says it cant' find IPlist, even though i have it in the same folder as the .bat file. I've also tried putting the path with it, but that didnt' work either. very strange.

Report Offensive Follow Up For Removal

Response Number 15
Name: Mechanix2Go
Date: November 7, 2005 at 13:02:50 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
After the first line, which is:

@echo off

put these and post what you get:

type IPlist
pause


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 16
Name: Mechanix2Go
Date: November 7, 2005 at 13:48:24 Pacific
Subject: Batch file to ping several servers.
Reply: (edit)
It's bedtime for Buckwheat.

I'll check in tomorrow.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch file to ping several servers.

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




how to setup call of duty to joytok

WindowsME / HotMail Problem

Corrupt memory

Convert fat32 to Ntfs

Best WinMo phone of 2008


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC