ant新建scp和sshexec任务
1、build.xml中新建targer如下:
<target name="remotecopytest" description="拷贝文件到远程服务器">
<scp file="C:\Users\testejb3\Workspaces\MyEclipse 8.5\helloworld\helloworld.jar" todir="root@192.168.152.129:/home/wsc/" trust="true" password="411816"></scp>
<echo message="上传完毕"></echo>
<sshexec failonerror="yes" host="192.168.152.129" username="root" password="411816" command="chown wsc:wsc /home/wsc/helloworld.jar" trust="true"></sshexec>
<echo message="修改文件属主完毕"/>
</target>
2、ant debug环境配置如下,运行
3、运行结果log
Apache Ant version 1.7.1 compiled on June 27 2008
Setting ro project property: ant.file -> C:\Users\testejb3\Workspaces\MyEclipse 8.5\helloworld\build.xml
Buildfile: C:\Users\testejb3\Workspaces\MyEclipse 8.5\helloworld\build.xml
Adding reference: ant.projectHelper
Adding reference: ant.parsing.context
Adding reference: ant.targets
parsing buildfile C:\Users\testejb3\Workspaces\MyEclipse 8.5\helloworld\build.xml with URI = file:/C:/Users/testejb3/Workspaces/MyEclipse%208.5/helloworld/build.xml
Setting ro project property: ant.project.name -> helloworld
Adding reference: helloworld
Setting ro project property: ant.file.helloworld -> C:\Users\testejb3\Workspaces\MyEclipse 8.5\helloworld\build.xml
Project base dir set to: C:\Users\testejb3\Workspaces\MyEclipse 8.5\helloworld
+Target:
+Target: echotest
+Target: remotecopytest
+Target: prepare
+Target: compile
+Target: ejbjar
+Target: deploy
+Target: undeploy
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
Setting project property: src.dir -> C:\Users\testejb3\Workspaces\MyEclipse 8.5\helloworld\src
[property] Loading Environment env.
Setting project property: env.TEMP -> C:\Users\testejb3\AppData\Local\Temp
Setting project property: env.ProgramW6432 -> C:\Program Files
Setting project property: env.JAVA_HOME -> C:\Program Files (x86)\Java\jdk1.6.0_32
Setting project property: env.ProgramFiles(x86) -> C:\Program Files (x86)
Setting project property: env.ProgramFiles -> C:\Program Files (x86)
Setting project property: env.Path -> C:/Users/testejb3/AppData/Local/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin/client;C:/Users/testejb3/AppData/Local/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin;C:\soft\jboss-4.2.3.GA\bin;C:\Program Files (x86)\Java\jdk1.6.0_32\bin;C:\Program Files\EmEditor;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
Setting project property: env.PSModulePath -> C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
Setting project property: env.SESSIONNAME -> Console
Setting project property: env.SystemRoot -> C:\Windows
Setting project property: env.USERNAME -> testejb3
Setting project property: env.CommonProgramW6432 -> C:\Program Files\Common Files
Setting project property: env.PROCESSOR_LEVEL -> 6
Setting project property: env.FP_NO_HOST_CHECK -> NO
Setting project property: env.USERPROFILE -> C:\Users\testejb3
Setting project property: env.PROCESSOR_REVISION -> 2a07
Setting project property: env.CommonProgramFiles -> C:\Program Files (x86)\Common Files
Setting project property: env.HOMEPATH -> \Users\testejb3
Setting project property: env.PROCESSOR_ARCHITECTURE -> x86
Setting project property: env.OS -> Windows_NT
Setting project property: env.LOCALAPPDATA -> C:\Users\testejb3\AppData\Local
Setting project property: env.ComSpec -> C:\Windows\system32\cmd.exe
Setting project property: env.PATHEXT -> .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Setting project property: env.PROMPT -> $P$G
Setting project property: env.ALLUSERSPROFILE -> C:\ProgramData
Setting project property: env.windows_tracing_flags -> 3
Setting project property: env.HOMEDRIVE -> C:
Setting project property: env.PROCESSOR_IDENTIFIER -> Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
Setting project property: env.APPDATA -> C:\Users\testejb3\AppData\Roaming
Setting project property: env.NUMBER_OF_PROCESSORS -> 1
Setting project property: env.JBOSS_HOME -> C:\soft\jboss-4.2.3.GA
Setting project property: env.ANT_HOME -> C:\Users\testejb3\AppData\Local\Genuitec\Common\plugins\org.apache.ant_1.7.1.v20090120-1145
Setting project property: env.ProgramData -> C:\ProgramData
Setting project property: env.CommonProgramFiles(x86) -> C:\Program Files (x86)\Common Files
Setting project property: env.PROCESSOR_ARCHITEW6432 -> AMD64
Setting project property: env.SystemDrive -> C:
Setting project property: env.TMP -> C:\Users\testejb3\AppData\Local\Temp
Setting project property: env.USERDOMAIN -> testweblogic-PC
Setting project property: env.windows_tracing_logfile -> C:\BVTBin\Tests\installpackage\csilogfile.log
Setting project property: env.windir -> C:\Windows
Setting project property: env.COMPUTERNAME -> TESTWEBLOGIC-PC
Setting project property: env.PUBLIC -> C:\Users\Public
Setting project property: env.LOGONSERVER -> \\TESTWEBLOGIC-PC
Setting project property: jboss.home -> C:\soft\jboss-4.2.3.GA
Setting project property: jboss.server.config -> default
Setting project property: build.dir -> C:\Users\testejb3\Workspaces\MyEclipse 8.5\helloworld\build
Adding reference: build.classpath
Adding reference: eclipse.ant.targetVector
Build sequence for target(s) `remotecopytest' is [remotecopytest]
Complete build sequence is [remotecopytest, echotest, prepare, compile, ejbjar, undeploy, deploy, ]
remotecopytest:
[scp] Connecting to 192.168.152.129:22
[scp] done.
[echo] 上传完毕
[sshexec] Connecting to 192.168.152.129:22
[sshexec] cmd : chown wsc:wsc /home/wsc/helloworld.jar
[echo] 修改文件属主完毕
BUILD SUCCESSFUL
Total time: 3 seconds
4、注意点
运行scp以及sshexec命令需要jscp的jar包,可以从地址:http://prdownloads.sourceforge.net/jsch/jsch-0.1.37.zip?download下载,这个源码,build出来一个jar包jsch-20140509.jar,放到ant的lib目录下面(这个目录信息在ant的出错信息里会有非常详细的提示,这里感觉ant做的很好),我这里用的是MyEclipse自带的ant环境,如下:
ant新建scp和sshexec任务的更多相关文章
- Java SCP copy local file to remote implementation
最近做的项目中,有一个小需求,需要通过SCP把本地文件copy到远程服务器.查了好多资料,最终解决方案简单快速,分享一下. 在这里,需要用到4个jar包,分别是ant-jsch.jar,ant-lau ...
- ant 安装过程中问题记录
最近在本机安装ant过程中出现一些问题,在此记录一下. 1.Unable to locate tools.jar. Expected to find it in C:/Program Files/Ja ...
- 从源码角度深入分析ant
Ant的基本概念 首先是ant的基本概念:Project,Target,Tasks,Properties,Paths 1.Project <project> build.xml文件最顶层的 ...
- 通过java程序调用ant build.xml配置文件中指定的target
一.概述 通过ant实现项目的自动化部署,jar包生成,替换,tomcat关停.启动,查看项目日志: 通过java程序调用已编辑好的ant脚本build.xml配置文件中指定的target: 文中文件 ...
- 从源码角度深入分析 ant
[转自] http://www.tuicool.com/articles/eQvIRbA Ant的基本概念 首先是ant的基本概念: Project,Target,Tasks,Properties,P ...
- ant 使用指南
一.概述 ant 是一个将软件编译.测试.部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发.在实际软件开发中,有很多地方可以用到ant. 开发环境: System:Windo ...
- (转)ant 使用指南
ant 使用指南 文件转载自:http://www.cnblogs.com/hoojo/archive/2013/06/14/java_ant_project_target_task_run.htm ...
- ant使用指南详细入门教程
这篇文章主要介绍了ant使用指南详细入门教程,本文详细的讲解了安装.验证安装.使用方法.使用实例.ant命令等内容,需要的朋友可以参考下 一.概述 ant 是一个将软件编译.测试.部署等步骤联系在一起 ...
- Eclipse下使用Ant 【转】
官方在线帮助文档:http://ant.apache.org/manual/index.html 中文汉化 帮助文档:http://www.cnblogs.com/pengxl/archive/201 ...
随机推荐
- JavaWeb基础:Servlet Request
Request获取请求头和请求数据 Request实现请求转发和MVC Request实现页面包含和Refresh
- php提示Fatal error: Call to undefined function imagecreate()
在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会 / ...
- 继承多态绕点 C#篇
最近在看博客的时候看到一块很绕的地方,有点类似于以前学习C语言是的i++,++i组合到一起使用的情况,很坑b的,绝对会比i++,++i这种情况更有用,虽然实际代码里面确实很少出现. 面对象像三大特点不 ...
- 用Google Analytics跟踪JavaScript Errors (译)
通过custom events来实施 // Track basic JavaScript errors window.addEventListener('error', function(e) { _ ...
- ANGULARJS 动态编译添加到dom中
在使用angularjs 时,希望通过动态构建angular模版,再通过angular进行展示. 使用 方法如下: <html ng-app="app"> <he ...
- VBA读取文件夹下所有文件夹及文件内容,并以树形结构展示
Const TR_LEVEL_MARK = "+"Const TR_COL_INDEX = "A"Const TR_COL_LEVEL = "E&qu ...
- NSArray和NSDictionary的混合
- plsql记住登录密码
登录plsql:tools(工具)->preference(首选项)->Login history(登录历史):选择"Store with password"(带口令存 ...
- bzoj 2049: [Sdoi2008]Cave 洞穴勘测
#include<cstdio> #include<iostream> using namespace std; ][],n,m,fa[],st[]; ]; bool isro ...
- LCD驱动 15-3
测试:1:make menuconfig去掉原来的驱动程序 Device Drivers ---> Graphics support ---> ...