在批处理文件中使用 AND 条件会导致问题
在我打开 echo 的批处理文件中
findstr SWITCHIDENTITY rf_monitor.out >nul 2>&1 && set IDENTITY_FOUND=true
findstr SWITCHUTILITY rf_monitor.out >nul 2>&1 && set UTILITY_FOUND=true
findstr "GP Manager connection successful" rf_monitor.out >nul 2>&1 && set GPMANAGER_FOUND=true
,下面是我看到的内容
D:\cvstags\trunk\regfortcms\install\win\scripts>findstr SWITCHIDENTITY rf_monito r.out 1>nul 2>&1 && set IDENTITY_FOUND=true D:\cvstags\trunk\regfortcms\install\win\scripts>findstr SWITCHUTILITY rf_monitor .out 1>nul 2>&1 && set UTILITY_FOUND=true D:\cvstags\trunk\regfortcms\install\win\scripts>findstr "GP Manager connection s uccessful" rf_monitor.out 1>nul 2>&1 && set GPMANAGER_FOUND=true **&& was unexpected at this time.**
为什么我会得到 &&这时候出乎意料
?如果我自己在 DOS 提示符下键入这三个命令,我不会收到任何此类消息。请指教。
In a batch file I have
findstr SWITCHIDENTITY rf_monitor.out >nul 2>&1 && set IDENTITY_FOUND=true
findstr SWITCHUTILITY rf_monitor.out >nul 2>&1 && set UTILITY_FOUND=true
findstr "GP Manager connection successful" rf_monitor.out >nul 2>&1 && set GPMANAGER_FOUND=true
with echo on, below is what I see
D:\cvstags\trunk\regfortcms\install\win\scripts>findstr SWITCHIDENTITY rf_monito r.out 1>nul 2>&1 && set IDENTITY_FOUND=true D:\cvstags\trunk\regfortcms\install\win\scripts>findstr SWITCHUTILITY rf_monitor .out 1>nul 2>&1 && set UTILITY_FOUND=true D:\cvstags\trunk\regfortcms\install\win\scripts>findstr "GP Manager connection s uccessful" rf_monitor.out 1>nul 2>&1 && set GPMANAGER_FOUND=true **&& was unexpected at this time.**
Why do I get that && was unexpected at this time
? If I type the three commands myself on the DOS prompt I don't get any such message. Please advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该死,错误消息不是关于我发布的行,而是关于我对 && 的使用。在 IF 条件下。看来我必须使用像 IF 条件1 IF 条件2 。
Goddammit, the error message had been not about the lines I posted but about my usage of && in an IF condition. It seems that I have to use like IF condition1 IF condition2 .