Your for-in-do was incorrect and a misplaced ( after the else
@echo off
for /f "delims=" %%i in ('type "D:\script\ip.txt" ') do (
pushd C:\Windows\System32\tools
plink.exe -l root -pw xxxx root@%%i lsb_release -sr | grep 12.04
if ERRORLEVEL 1 (
msg * Sorry, this is NOT a Precise version
pause
exit /b
) else (
msg * Cheers, welcome to Precise!
)
popd
)
This is in answer to the followup details - it may need some work as I don't know how plink works or the way it handles Linux commands.
@echo off
for /f "delims=" %%i in ('type "D:\script\ip.txt" ') do (
pushd C:\Windows\System32\tools
plink.exe -l root -pw xxxx root@%%i lsb_release -sr | grep 12.04
REM if 12.04 not found then print message and abort
if ERRORLEVEL 1 (
echo Sorry, Ubuntu 12.04 is required.
pause
exit /b
)
plink.exe -l root -pw xxxx root@%%i (dpkg -l | grep libreoffice-core
REM if libre is found and errorlevel is zero then abort silently
if not ERRORLEVEL 1 (
exit /b
) else (
REM if it reaches here then it will install LibreOffice
plink.exe -l root -pw xxxx root@%%i sudo apt-get install libreoffice
)
popd
)