设为首页 收藏本站
查看: 1013|回复: 0

[经验分享] How To Run Ant FTP / Telnet / Rexec Task

[复制链接]

尚未签到

发表于 2016-6-10 09:53:23 | 显示全部楼层 |阅读模式
  BY ANGSUMAN CHAKRABORTY, GAEA NEWS NETWORKWEDNESDAY, NOVEMBER 2, 2005

  Ant(javasoftware) from Apache Foundation is a popular build tool (often used successfully with other release management tasks) which replaces make.
  
  “Apache Ant is aJava-based build tool. In theory, it is kind of like Make, but without Make’s wrinkles. ”
  Included in Ant are optional tasks likeFTP& Telnet. For example the FTP Task allows you to communicate with FTP servers (get / put / list etc.).
  Unfortunately they don’t work out of box and not well documented. In this article we will explain the whole procedure in six simple steps.
  To use them follow the steps below:


  • Downloadjakarta-oroandcommons-netlibrary.
    Note: The links above allow you to download the version I tested them with.
  • Create a lib directory for your project if you have not already done so.
  • Extract the jar file jakarta-oro*.jar fromjakarta-orolibrary you have downloaded and copy it to the lib directory you created.
    Note:  

    • If you have downloaded from the links in step 1 then the exact file name isjakarta-oro-2.0.8.jar
    • Ensure that the file is copied to the lib directory and not to any of its sub-directories


  • Extract the jar file commons-net*.jar file fromcommons-netlibrary you have downloaded and copy it to the lib directory.
    Note:  

    • If you have downloaded from the links in step 1 then the exact file name iscommons-net-1.4.0.jar
    • Ensure that the file is copied to the lib directory and not to any of its sub-directories


  • Add the ftp taskdef at the top:
    <taskdef name=”ftp” classname=”org.apache.tools.ant.taskdefs.optional.net.FTP”/>
  • Add the appropriate task to your build.xml file. An example task to upload a directory is as follows:
    http://blog.taragana.com/wp-content/uploads/2005/11/code.png
  • Run Ant by including the lib directory in classpath. An example would be:
    ant -lib lib upload
      Note: I just had to include the lib directory to ensure all its jar files are automatically included.

  Note:


  • The same procedure can be used to run Ant Telnet and RExec Tasks. Only the task name and parameters in build.xml file will change. Check the corresponding manuals for details.
  • I have promoted the use of lib directory (within project) to keep your jar files. This makes your jar files available only to your project. There are two other alternatives. First you can keep them in%ANT_HOME%/libdirectory. This makes them available to all projects for all users in that machine.
    You can also keep them in${user.home}/.ant/lib.  

      The location of ${user.home}/.ant/lib is somewhat dependent on the JVM. On Unix systems ${user.home} maps to the user’s home directory whilst on recent versions of Windows it will be somewhere such as C:/Documents and Settings/username/.ant/lib.
      





      用Eclipse3.3+Ant1.7.0,在build.xml文件中使用ftp将包发到远程服务器上时总是出错,出错信息为:
      “Could not create type ftp due to java.lang.NoClassDefFoundError:
      org/apache/commons/net/ftp/FTPClientConfig”
      结果Google了N久,知道是少了两个包:commons-net-1.4.1.jar和jakarta-oro-2.0.8.jar
      把这两个包放到Eclipse的Ant的lib目录下,在Eclipse重新执行ant,问题依然存在。结果又Google了很久,最终,在一篇外国博文 中找到解决方法,原文如下
      “I had the same error message, but only in Eclipse (version 3.3).
      I did not get the error on command line. I had setup up ANT_HOME variable correctly and copied the jakarta-oro-2.0.8.jar and commons-net-1.4.1.jar to %ANT_HOME%/lib
      However it seems that the ANT Eclipse module does not automatically parse the %ANT_HOME%/lib directory for new jars and I had to add them manually
      preferences->Ant->Runtime, Classpath tab, Ant Home Entries -> Add External JARs...
      Then it worked. ”




  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-228517-1-1.html 上篇帖子: VC实现上传文件到FTP服务器 下篇帖子: 利用apache显示ftp服务器上的图片
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表