1. 远程服务器
Reference:http://ant.apache.org/manual/Tasks/sshexec.html
Runs a command on a remote machine running SSH daemon.
Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information. This task has been tested with jsch-0.1.29 and above and won't work with versions of jsch earlier than 0.1.28.
执行这个命令的时候需要下载第三方依赖包jsch-0.1.46.jar到ant/lib目录。
<sshexec host="${host}" username="${usr}" password="${pwd}" trust="true" command="pwd;./test.sh" outputproperty="output" />
这样在后续的ant脚本中就可以用${output}来取得脚本的运行结果了。
2.本地脚本
Reference : http://ant.apache.org/manual/Tasks/exec.html
<exec dir="${tools.dir}" executable="xx.sh或xx.bat或xx.exe" outputproperty="platform.type" />
这样在后续的ant脚本中就可以用${platform.type}来取得脚本的运行结果了。