Ping computers from txt / csv

ok I have had a look at other questions on here about this and I'm struggling to get them to work correctly.
What I have is a txt /csv file listing host names of computers
What I want is to ping this list and log result to a txt /csv file.
I would like the result file to contain the host name and then the IP address and the time & date, if the host name doesn't respond I would like it to just so unable to connect or something like this.

I know this must be possible but I'm very new to this.  I don't mind if I have to enter the syntax directly into the into the cmd prompt or if its a batch file.

Can anyone help, this is quite urgent
cochAsked:
Who is Participating?
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.

simkoCommented:
you can use nmap<or other scan sw> for this and than redirect the output to a txt file

for x smaple like this
nmap -sP 192.168.3.0/24 > /tmp/out

this will ping all the hosts in the 192.168.3.0 subnet ant the result will be stored in the /tmp/out directory

in M$ W it will work also but you canot redirect the output with >

regards
R.
0
cochAuthor Commented:
thanks but its not quite what I'm looking for.  What I have is query output from Active Directory of all NT4 machines that have changed their passwords since 10th April 2006.  What I want to do is to ping each hostname in this list and log the results.
0
Steve KnightIT ConsultancyCommented:
A batch file like this should work .... mangled from an existing one that does net use drive mapping checks to a series of servers so may be some typos:

using a file hostlist.txt entered as

hostname,ipaddress
nexthost,nextipaddress

it creates logfile.txt. PING doesn't return an errorlevel on all Windows OS's so try it and see:

PING knownhost
echo %errorlevel%
PING duffaddress
echo %errorlevel%

if this returns something other than 0 it should work...

set logfile=logfile.txt
set hostlist=hostlist.txt
for /F  "tokens=1,2 delims==," %%i IN (%hostlist%) DO call :pinghost %%i %%j
goto end

:pinghost
  SET SERVER=%1
  SET IPAD=%2
  ping -n 1 %ipad%
  if "%errorlevel%"=="0" echo PING to %SERVER% (%IPAD%) OK >> %logfile%
  if not "%errorlevel%"=="0" echo PING to %SERVER% (%IPAD%) FAILED >>%logfile%
goto end

:end
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Steve KnightIT ConsultancyCommented:
If you haven't got IP addresses in the file then change the for line to

set logfile=logfile.txt
set hostlist=hostlist.txt
for /F  %%i IN (%hostlist%) DO call :pinghost %%i
goto end

:pinghost
  SET SERVER=%1
  ping -n 1 %server%
  if "%errorlevel%"=="0" echo PING to %SERVER% OK >> %logfile%
  if not "%errorlevel%"=="0" echo PING to %SERVER% FAILED >>%logfile%
goto end

0

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
cochAuthor Commented:
works  a treat dragon-it, thank you
0
Steve KnightIT ConsultancyCommented:
Thought it should :-)  Thanks for the points.

Steve
0
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
Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.