标题: 批处理中使用findstr查找字符串结果执行不同的语句 [打印本页]
作者: lxlsh 时间: 2014-2-14 15:32 标题: 批处理中使用findstr查找字符串结果执行不同的语句
想在批处理中使用findstr,通过管道命令,有如下的语句:
netstat -an | findstr %APP_SVR_PORT% | findstr LISTENING >nul,我想判断findstr最后的结果如果是空的就执行某个语句,如果不是的话就不执行。
请问各位大侠应该怎么来写?
作者: Batcher 时间: 2014-2-14 15:59
- netstat -an | findstr %APP_SVR_PORT% | findstr LISTENING >nul || echo hello
复制代码
作者: lxlsh 时间: 2014-2-14 16:05
回复 2# Batcher
在CMD里面执行了一下,不能输出hello,如图
作者: Batcher 时间: 2014-2-14 17:11
回复 3# lxlsh - netstat -an | findstr 12345 | findstr LISTENING >nul || echo hello
复制代码
这样试试
作者: lxlsh 时间: 2014-2-15 16:57
回复 4# Batcher
这句命令和我上面截图里面的已经试过的,都不行的啊
作者: Batcher 时间: 2014-2-15 22:16
回复 5# lxlsh
把执行4楼代码的截图发出来看看
作者: lxlsh 时间: 2014-2-16 17:55
回复 6# Batcher
已经解决了这个问题,谢谢你的帮助
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |