简体   繁体   English

Windows bat文件如何验证命令输出

[英]Windows bat file how to verify output of a command

I want to verify an installation on a windows (XP) machine. 我想验证Windows(XP)计算机上的安装。 So i want to create a .bat file that does the work. 所以我想创建一个工作的.bat文件。

I want to verify commands like 我想验证类似的命令

jruby --version jruby --version

and echo "OK" if it gives reasonable output. 如果给出合理的输出,则回显“ OK”。 So in pseudocode: 所以在伪代码中:

if( `jruby --version`.startsWith("jruby 1.5.6") then 
  echo "OK"
else
  echo "FAIL: Jruby not working!"

Any ideas on how to make that comparison in a bat file? 关于如何在bat文件中进行比较的任何想法?

@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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows中执行命令行输出而不必生成bat文件? - How can I execute command line output in windows without having to generate a bat file? 如何使用bat文件响应命令行提示符(Windows) - How to respond to command line prompt using bat file (Windows) 如何在Windows中的bat脚本中将输出定向到txt文件 - how to direct output into a txt file in bat script in windows 如何在 windows.bat 文件中捕获的命令中获取所有 arguments - how to get all the arguments in a command captured in a windows .bat file Windows命令可在cmd中工作,但不能在.bat文件中工作 - Windows command working in cmd but not in .bat file Windows 命令在 cmd 但不是 .bat 文件中工作 - Windows command working in cmd but not .bat file Windows 7 bat文件遗漏了部分命令 - windows 7 bat file leaves out parts of the command 如何开发Windows服务来处理bat命令 - How to develop windows service to handle bat command 将python命令的输出重定向到在cmd中工作但不在.bat文件中工作的txt文件,如何解决? - redirecting the output of a python command to a txt file working in cmd but not in .bat file, how to solve? 如何从Windows命令行执行外部PHP文件(bat文件) - How to execute an external PHP file from a Windows Command Line (bat file)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM