我无法弄清楚 commandResource 的实际外观。我见过的唯一例子是下面列出的 Apache's page (不是很有帮助)
<sshexec host="somehost"
username="dude"
keyfile="${user.home}/.ssh/id_dsa"
commandResource="to_run"/>
所以我的作品看起来像这样
<sshexec host="${host}"
trust="yes"
username="${username}"
password="${password}"
commandResource="Commands.txt"/>
如何设计Commands.txt的格式?我想做的是:
命令一:sudo user runscript.sh
命令2:“${password}”(脚本中也需要输入密码)
最佳答案
可以在相关的 bug 中找到示例
Commands.txt:
touch 1.txt
mv 1.txt 2.txt
mv 2.txt 3.txt
每一行必须包含一个必须执行的命令。
您尝试做的事情不会奏效。您不能那样设置密码,这不是命令而是控制台输入。
也许您应该只授予用户执行此脚本的 sudo 权限。
关于Ant sshexec 命令资源示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8217871/