【发布时间】:2023-03-06 16:48:01
【问题描述】:
我正在尝试从 Apache ant 执行 "who -m" 命令,但没有成功。
这是我的 ant 脚本:
<?xml version="1.0" encoding="UTF-8"?>
<project name="default" default="who.am.i">
<target name="who.am.i">
<exec executable="who" outputproperty="myOutput">
<arg value="-m"/>
</exec>
<echo message="I am = ${myOutput}"/>
</target>
</project>
结果为空。
[echo] I am =
如果我在没有参数的情况下运行 exec,它会显示正确的结果:
<exec executable="who" outputproperty="myOutput">
</exec>
[echo] host.name = gary tty8 2014-02-03 12:04 (:0)
[echo] gary pts/0 2014-02-03 12:09 (:0)
[echo] gary pts/1 2014-02-03 12:23 (:0)
[echo] gary pts/2 2014-02-04 11:36 (:0)
[echo] gary pts/4 2014-02-05 13:27 (:0)
[echo] gary pts/7 2014-02-04 12:23 (:0)
[echo] gary pts/8 2014-02-06 12:44 (:0)
如果我从终端运行 who -m 命令,它会显示我要查找的内容:
who -m
gary pts/8 2014-02-06 12:44 (:0)
任何想法为什么 ant 不接受 -m 参数?
【问题讨论】: