jeudi 23 mars 2017

Batch - For /F with IF/File/Comparison

Dears,

I'm hoping you can help me, because I lost my faith. Let me show you what I have done, and then explain what I need to achive.

@echo off    
echo "Which Site do you want to check?"
set /p ans="Site: "
echo.

for /f "tokens=1,2,3 delims=," %%A IN (animals.csv) DO if %%A==%ANS% (ping %%B AND ping %%C)
echo.
pause
echo.
cls
goto menu

  1. User should put something animal name which will be stored in ANS variable.
  2. Script should check in animals.csv what IP adresses are assigned for that animal.
  3. After matching, script should ping IP adresses in next columns, so user could see results. PS: All both files are in the same folder.

Problem is that animals.txt has 3 columns and a lot of records. I was able make script work till point of comparing variables, then I stopped working.

Let's say that animals file looks like that:

cat,111.111.111.111,122.122.122.122 
dog,222.222.222.222,233.233.233.233 
horse,333.333.333.333,344.344.344.344

Help me, because I stuck and I have no damn clue how to do it.

Aucun commentaire:

Enregistrer un commentaire