Solved

DOS Command  OR Scripts

Posted on 2013-11-19
6
348 Views
Last Modified: 2013-12-04
Hi EE,

I am looking for the scripts or command to ping the list servers that located in domain from text or excel file and get the result in notepad, Could any one help on this? Please and Thank you

Regards,
J Peter
0
Comment
Question by:Jey_P
6 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 100 total points
ID: 39659804
From a command line:
for /f %a in (c:\servers.txt) do ping %a -n 1 >> results.txt

or in a batch file:

@echo off
for /f %%a in (c:\servers.txt) do ping %%a -n 1 >> results.txt

Open in new window

0
 
LVL 83

Assisted Solution

by:oBdA
oBdA earned 50 total points
ID: 39659814
Batch file that creates a csv:
@echo off
setlocal
set ServerFile=Servers.txt
set LogFile=%~dpn0.csv
set CsvDelim=,
if exist "%LogFile%" del "%LogFile%"
for /f %%a in ('type "%ServerFile%"') do (
	echo Processing %%a ...
	ping -4 -n 4 %%a | find /i "TTL" >NUL
	if errorlevel 1 (
		>>"%LogFile%" echo %%a%CsvDelim%Error 
		echo ... offline.
	) else (
		echo ... responding.
		>>"%LogFile%" echo %%a%CsvDelim%Success
	)
)
echo Done.
start "" notepad.exe "%LogFile%"

Open in new window

0
 
LVL 13

Expert Comment

by:duncanb7
ID: 39659828
Hope it will help
@echo off
:Start

REM cd "c:\your location if you need"
for /f "tokens=* delims=" %%x in (d:\ping.txt) do ping %%x
echo.
echo.

Open in new window

0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 50 total points
ID: 39659837
Wit PowerShell...
Try..
GC C:\Server.txt | % {
$Server = $_
 If (Test-Connection $Server -Quiet){
	 New-Object PSOBJect -Property @{
	 Server = $Server
	 Status = "UP"
 	}
 }
 Else{
	 New-Object PSOBJect -Property @{
	 Server = $Server
	 Status = "Down"
         }
 }
} | Export-Csv C:\report.csv -nti

Open in new window

Input file..
ServerA
ServerB
ServerC

Open in new window

0
 
LVL 13

Assisted Solution

by:duncanb7
duncanb7 earned 25 total points
ID: 39659863
it works with less code
@echo off
:Start
del -f out.txt
REM cd "c:\your location if you need"
REM ping.txt store all your server name
for /f "tokens=* delims=" %%x in (c:\ping.txt) do ping %%x>>out.txt
start  notepad.exe "out.txt"

Open in new window

0
 
LVL 15

Assisted Solution

by:David L. Hansen
David L. Hansen earned 25 total points
ID: 39659867
You can use MS Powershell to do this (and it's free).  Here are a couple of links to show you where people are already doing exactly the same thing you are trying.

http://powergui.org/thread.jspa?threadID=20236

http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_26672523.html

It is included in the Windows Management Framework download here.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
A procedure for exporting installed hotfix details of remote computers using powershell
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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