Ant sshexec命令资源示例

3

我在弄清楚commandResource到底是什么样子时遇到了困难。我看到的唯一一个例子是Apache页面上列出的(不是很有用):

<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的格式?我想要实现以下功能:
命令1:sudo user runscript.sh
命令2:"${password}" (密码也需要在脚本中输入)
1个回答

2
您可以在相关的错误中找到一个示例。 Bug链接中有详细信息。
Commands.txt:             
touch 1.txt
mv 1.txt 2.txt
mv 2.txt 3.txt

每一行都必须包含一个要执行的命令。
你试图这样做是不会起作用的。你不能以这种方式设置密码,这不是一个命令,而是控制台输入。
也许你应该给用户sudo权限来执行这个脚本。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接