Link to home
Start Free TrialLog in
Avatar of Ted Penner
Ted PennerFlag for United States of America

asked on

Syntax to resolve hostname

I need a command that will look at file hostname.txt and produce an ip.txt from it.  Assistance is greatly appreciated.
SOLUTION
Avatar of Guru Ji
Guru Ji
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ted Penner

ASKER

Thanks Ji and David.  It appears that running Powershell scripts is disabled.  However, the script below does produce an Output.csv file with two named columns, but no actual data.
@echo off
 set HostList=C:\Hostnames.txt

 Echo Hostname,IP>Output.csv
 setlocal enabledelayedexpansion

 for /f “usebackq tokens=*” %%A in (“%HostList%”) do (
 for /f “tokens=3” %%B in (‘ping -n 1 -l 1 %%A ^|findstr Reply’) do (
 set IPadd=%%B
 echo %%A,!IPadd:~0,-1!>>Output.csv
 ))

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial