Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用ant sshexec执行sudo命令_Ant_Command_Sudo - Fatal编程技术网

如何使用ant sshexec执行sudo命令

如何使用ant sshexec执行sudo命令,ant,command,sudo,Ant,Command,Sudo,我正试图用sudo在远程服务器上执行这样的命令 <target name="remote-test"> <sshexec host="${remote.host}" username="${remote.user}" password="${remote.pass}" trust="true" usepty="true" command="sudo ls /home/myuser" />

我正试图用sudo在远程服务器上执行这样的命令

<target name="remote-test">
    <sshexec host="${remote.host}"
        username="${remote.user}"
        password="${remote.pass}"
        trust="true"
        usepty="true"
        command="sudo ls /home/myuser" />
</target>
那么,如何使用ant使用sudo执行远程命令呢


谢谢:)

是的,也许可以这样复制:

但不管怎样,解决这个问题的一个办法是,在美国投票最多的答案中这样说

<target name="remote-test-jboss">
    <sshexec host="${remote.host}"
        username="${remote.user}"
        password="${remote.pass}"
        command="echo ${remote.pass}| sudo -S ls /home/myserver" 
        trust="true"
    />
</target>

-S参数用于从标准输入读取。

可能重复的
<target name="remote-test-jboss">
    <sshexec host="${remote.host}"
        username="${remote.user}"
        password="${remote.pass}"
        command="echo ${remote.pass}| sudo -S ls /home/myserver" 
        trust="true"
    />
</target>