`
aryanwang
  • 浏览: 18620 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

Ant-sshexec-执行远程服务器或本地脚本

 
阅读更多

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}来取得脚本的运行结果了。

 

 

 

 

 

分享到:
评论
1 楼 aryanwang 2012-02-17  
如果想执行命令,则可以使用如下格式,不要用command属性,这个已经被弃用了。传递参数用arg标签
				
<exec 
  dir="${tools.dir}" 
  executable="uname"   
  outputproperty="platform">				
    <arg value="-s"></arg>				
</exec>

相关推荐

Global site tag (gtag.js) - Google Analytics