如何使用 Apache Ant exec 任务记录 cmd tree 命令的输出?
我正在尝试使用 ant 记录 cmd tree 命令的输出,内容如下:
<exec dir="${basedir}" executable="cmd" output="output.txt">
<arg value="tree" />
</exec>
但是,我在“output.txt”中看到以下内容:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
当我在 Windows cmd 中运行命令时:
C:\tree>tree
我得到类似以下内容:
C:\tree
└───test
└───test
谁能告诉我我如何编写一个 Ant 脚本来将树结构打印到文件中?
I am trying to log the output from cmd tree command using ant with the following:
<exec dir="${basedir}" executable="cmd" output="output.txt">
<arg value="tree" />
</exec>
However, I am seeing the following in the "output.txt":
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
When I run the command in the windows cmd:
C:\tree>tree
I get something like:
C:\tree
└───test
└───test
Can anyone tell me how to write a Ant script to print the tree structure in to a file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尝试执行
tree.com
。来自 exec 的文档:您需要明确调用
tree.com
。另一种方法是指定
cmd
的/C
参数,这对我有用:You try to execute
tree.com
. From the documentation of exec:You need to call
tree.com
explicitely.Another way is to specify the
/C
parameter ofcmd
, that's what worked for me:(这里猜测,我不是 Ant 用户)
如果您在命令提示符中键入内容
,您也不会看到除了
仅执行
tree
怎么样?(Guessing here, I'm no Ant user)
If you would type
into the command prompt you also wouldn't see more than
What about just executing
tree
?