如何使用apacheantexec任务记录cmdtree命令的输出?
我尝试使用ant记录cmd tree命令的输出,如下所示:如何使用apacheantexec任务记录cmdtree命令的输出?,ant,cmd,exec,Ant,Cmd,Exec,我尝试使用ant记录cmd tree命令的输出,如下所示: <exec dir="${basedir}" executable="cmd" output="output.txt"> <arg value="tree" /> </exec> 在windows cmd中运行命令时: C:\tree>tree 我得到的结果是: C:\tree └───test └──
<exec dir="${basedir}" executable="cmd" output="output.txt">
<arg value="tree" />
</exec>
在windows cmd中运行命令时:
C:\tree>tree
我得到的结果是:
C:\tree
└───test
└───test
有人能告诉我如何编写Ant脚本将树结构打印到文件中吗?(猜猜,我不是Ant用户)
如果你想打字的话
cmd tree
在命令提示符中,您也不会看到超过
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
只执行树
怎么样
<exec dir="${basedir}" executable="tree" output="output.txt"/>
您尝试执行
tree.com
。从:
[…]特别是,如果您不
仅可执行文件上的文件扩展名
将查找“.EXE”文件,而不是
.COM、.CMD或其他文件类型
在环境变量中列出
PATHEXT。这只供用户使用
贝壳
您需要明确地调用tree.com
<exec dir="${basedir}" executable="tree.com" output="output.txt" />
+1
tree
是一个常规的命令行应用程序(tree.com
),而不是一个内置命令,因此不需要调用cmd
好吧,我得到了以下建议的错误:“无法运行程序”tree:CreateProcess error=2,系统找不到指定的文件。”您可能需要稍微更改它。TREE[drive:][path][/F][/A]So executable=“TREE${basedir}”或甚至executable=“TREE${basedir}>${basedir}\output.txt”谢谢,但我收到了相同的错误“无法运行程序”TREE C:\TREE”:CreateProcess error=2,系统找不到指定的文件。”我想建议使用cmd/c
,但认为调用shell只是调用控制台程序有点多余。不知道ant忽略了PATHEXT:-)
<exec dir="${basedir}" executable="tree.com" output="output.txt" />
<exec dir="${basedir}" executable="cmd" output="output.txt">
<arg value="/C" />
<arg value="tree" />
</exec>