开发者

Windows bat file how to verify output of a command

I want to verify an installation on a windows (XP) machine. So i want to create a .bat file that does the work.

I want to verify commands like

jruby --version

and echo "OK" if it gives reasonable output. So in pseudocode:

if( `jruby --version`.startsWith("jruby 1.5.6") then 
  开发者_如何学Goecho "OK"
else
  echo "FAIL: Jruby not working!"

Any ideas on how to make that comparison in a bat file?


@echo off
jruby --version 2>&1 | findstr /I /C:"jruby 1.5.6" > nul

if %errorlevel% == 0 (
    echo "OK"
) else (
    echo "FAIL: Jruby not working!"
)

pause
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜