0

This is giving me little headache.

I fillup an array with ip adresses and hostnames. When filling the array the corresponding element shows added to the array.

Data for sentinels.txt:

127.0.0.1 loopback 192.168.100.102 printer

When populating the array afterwards it is empty??

    SET /a HostCount=0
    FOR /F "tokens=1,2 delims= " %%A in (Sentinels.txt) DO (
    SET ListHosts[%HostCount%]=%%A
    ECHO !HostCount! !ListHosts[%HostCount%]!
    )

    REM Check if array ListHosts is empty
    IF not "%ListHosts%"=="" (
    FOR /f %%i IN (%ListHosts%) DO (
    ECHO %%i
    )           
    )

Thanks in advance, I need the solution to be compatible with an array, a shown in the sample code, the existing questions here are all using a list example.

Stephan
  • 1,548
  • 1
  • 10
  • 10
Steev
  • 1
  • 1

0 Answers0