2013-06-15 3 views
0

Windows 일괄 처리 스크립트와 plink.exe 도구 (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)를 결합하여 루프로 실행하고 싶지만 아래 행운은 내 것이 아닙니다. 당신의 도움이Windows 일괄 처리 스크립트 및 plink.exe

@echo off 
for /f %%i in (D:\script\ip.txt) do (
pushd C:\Windows\System32\tools 
plink.exe -l root -pw xxxx [email protected]%%i lsb_release -sr | grep 12.04 
if ERRORLEVEL 1 (
msg * Sorry, this is NOT a Precise version 
exit 
) else 
(
pushd C:\Windows\System32\tools 
msg * Cheers, welcome to Precise! 
) 
) 

또는 단순히 루프로 Windows 배치 스크립트를 실행하기위한 감사합니다.

if it is Ubuntu 10.04 
do nothing 
else if (meant, it's Ubuntu 12.04) 
already LibreOffice installed 
do nothing 
else 
install LibreOffice 
exit 

과 ip.txt 파일

+0

오류가 무엇입니까? 단 하나의 IP에서만 작동합니까? –

+0

안녕하세요, 나는 아무것도 얻지 못했지만 제대로 작동하지 않는 것 같습니다. (: \ 스크립트 \의 ip.txt D)을 수행 ( PUSHD의 C : \ WINDOWS \ SYSTEM32 \ 도구 plink.exe -l 루트 -pw 는/F %% 난에 대한 을 @echo 경우 –

+0

는 단지 일했다 xxxx root @ %% i "lsb_release -sr | grep 12.04"> D : \ debug.txt ) –

답변

1

에서 다음 IP 주소로 반복 귀하에 대한-에서 할 일이 잘못되고이가 대답에 잘못합니다 (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 [email protected]%%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 
) 

후 추가 정보 - plink가 어떻게 작동하는지 또는 리눅스 명령을 처리하는 방식을 모르므로 일부 작업이 필요할 수도 있습니다.

@echo off 
for /f "delims=" %%i in ('type "D:\script\ip.txt" ') do (
pushd C:\Windows\System32\tools 
plink.exe -l root -pw xxxx [email protected]%%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 [email protected]%%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 [email protected]%%i sudo apt-get install libreoffice 
) 
popd 
) 
+0

완벽하게 작동합니다. 게다가, 당신의 제안은 단지 2 가지 조건을 해결합니다. 더 많은 조건으로 해결할 수 있다면 많은 도움이 될 것입니다. LibreOffice와 이미 아무것도 다른 설치를하지 않는다 설치 LibreOffice와 경우 반복 –

+0

난 당신이 사용하는 어떤 명령) LibreOffice와는 B 설치되어있는 경우) 방법을 결정하기 위해 말해 줄 필요가 우분투 10.04 경우 아무 것도 을하지 않는다 : 그것은 같은 것이 보인다 LibreOffice를 설치하십시오. – foxidrive

+0

안녕하세요, LibreOffice가 이미 설치되어 있는지 확인하려면 (dpkg -get-selections | grep libreoffice-core | awk '{print $ 1}') 또는 (dpkg -l | grep libreoffice-core | awk '{print $ 2} '). LibreOffice를 설치하려면 repo에서 설치한다고 가정하고 (sudo apt-get install libreoffice) 진행합니다. Tks. –

관련 문제