怎样把bat中别的exe的输出结果当成变量继续运行bat?

xiaohou0701 2010-09-17 12:54:18
这个是bat里的一段代码
@set WORKFOLD=$/vsstest913
ss Checkout "%WORKFOLD%/hello.txt"
调用了vss后,ss.exe会输出一段反馈字符串,如:
"You currently have file $/vsstest913/hello.txt checked out"
我想要把这段输出当成变量string,继续下面的代码:
IF string = *** do [command]
不知道应该怎样实现呢?

用FOR /F "usebackq delims=" %i IN (`ss Checkout "%WORKFOLD%/hello.txt"`) DO @echo --%i--
貌似没有什么用.
...全文
263 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
CCWRSS 2011-07-19
  • 打赏
  • 举报
回复
找不到SS.exe
xiaohou0701 2010-09-26
  • 打赏
  • 举报
回复
还是不行。
C:\>FOR /F "usebackq delims=" %i IN ('ss Checkou
t "%WORKFOLD%/hello.txt" 1^>con 2^>con') DO @echo --%i--
--ss Checkout "$/vsstest913/hello.txt" 1>con 2>con--
系统找不到文件 ƸƸ。

就是just4 2010-09-18
  • 打赏
  • 举报
回复
楼主到底要实现什么呢?

SS Checkout "%WORKFOLD%/hello.txt" >1.log,就是说这条命令加了重定向符的?

for中要调用SS Checkout "%WORKFOLD%/hello.txt" >1.log应该是SS Checkout "%WORKFOLD%/hello.txt" ^>1.log

看来楼主这个问题有可能与SS有关,You currently have file $/vsstest913/hello.txt checked out,楼主不防这样测试:

[code=BatchFile]rem 错误输出测试
FOR /F "usebackq delims=" %i IN ('ss Checkout "%WORKFOLD%/hello.txt" 1^>con 2^>con') DO @echo --%i--
[/code]
xiaohou0701 2010-09-18
  • 打赏
  • 举报
回复
补充:
SS Checkout "%WORKFOLD%/hello.txt" >1.log
我把输出定向到文件里面,得到的是一个空文件.
而cmd里面还是会打印出:
You currently have file $/vsstest913/hello.txt checked out.

这个说明啥?不是那条命令返回的结果?
这样的输出,应该怎样捕捉?
xiaohou0701 2010-09-18
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 just4 的回复:]
怎么没用?没ss.exe,直接echo测试:


BatchFile code
set WORKFOLD=$/vsstest913
for /f "delims=" %i in ('echo ss Checkout "%WORKFOLD%/hello.txt"') do echo %i
[/Quote]

没有用,很明显那个返回并没有赋值到%i中.执行后输出是这样的:

C:>for /f "delims=" %i in ('ss Checkout "%WORKF
OLD%/hello.txt"') do echo --%i--
You currently have file $/vsstest913/hello.txt checked out.

ljc007 2010-09-17
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lfsfxy9 的回复:]
%i 就是那个参数哈。
[/Quote]

for循环的控制变量
类似C语言的for (i=1;i<10;i++)里面的i
我是一道光_ 2010-09-17
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 just4 的回复:]
怎么没用?没ss.exe,直接echo测试:


BatchFile code
set WORKFOLD=$/vsstest913
for /f "delims=" %i in ('echo ss Checkout "%WORKFOLD%/hello.txt"') do echo %i
[/Quote]

%i 就是那个参数哈。

就是just4 2010-09-17
  • 打赏
  • 举报
回复
怎么没用?没ss.exe,直接echo测试:

[code=BatchFile]set WORKFOLD=$/vsstest913
for /f "delims=" %i in ('echo ss Checkout "%WORKFOLD%/hello.txt"') do echo %i[/code]

6,211

社区成员

发帖
与我相关
我的任务
社区描述
windows网络管理与配置
社区管理员
  • 网络管理与配置社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧