Solved

Ant using FTP action to remove a directory

Posted on 2004-08-04
9
2,270 Views
Last Modified: 2010-05-18
I'm having a problem removing a directory with the FTP acion in Ant.  It says that rmdir is not a legal value for the ftp attribute.  Here is some of the code.  The "del" and "mkdir" actions work.

Any help resolving this is appreciated!


************ CODE SNIPPET *********************
<target name="FTPFiles" depends="init">

      <ftp action="del"
            server="${WASServer.DEV}"
            port="21"
            remotedir="/local/WebSphere/deploy/${property.app.name}/common"
            userid="wsadmin"
            password="${wsadmin.password}">
      <fileset>
            <include name="**"/>
      </fileset>
      </ftp>

      <ftp action="mkdir"
       server="${WASServer.DEV}"
       userid="wsadmin"
       password="${wsadmin.password}"
       remotedir="/local/WebSphere/deploy/${property.app.name}/testdir">
      </ftp>

      <ftp action="rmdir"
            server="${WASServer.DEV}"
            port="21"
            remotedir="/local/WebSphere/deploy/${property.app.name}/common" >
            userid="wsadmin"
            password="${wsadmin.password}"
      <fileset>
            <include name="**"/>
      </fileset>
      </ftp>
************ END CODE SNIPPET *********************

********** LOG FILE *********************
FTPFileTask:
     [echo] Build ALL for FTPBuildFiles at 05:01:53
     [echo] JAVA Version 1.3
     [echo] ScriptEngine

init:

FTPFiles:
      [ftp] deleting files
      [ftp] 5 files deleted
       [if] Error in class net.sf.antcontrib.logic.IfTask

BUILD FAILED
file:C:/ccBuild/ANT_vob/Ant/Build/FTPSECommonFiles.xml:104: rmdir is not a legal value for this attribute

Total time: 1 second
******************* END LOG FILE *********

0
Comment
Question by:lphillips120898
  • 5
  • 3
9 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
rmdir is not a valid action.
I don't think the ant task supports removing directories, but try using the del action.
0
 
LVL 7

Expert Comment

by:grim_toaster
Comment Utility
-->rmdir is not a valid action.
Unless it didn't exist in a previous version of ant (which version are you using?), the link below for the 1.6.2 manual shows that it is valid.
http://ant.apache.org/manual/OptionalTasks/ftp.html

However, you rmdir tag appears wrong.  You hava the closing ">" halfway through, is this just a copy/paste error, as you should have got a parse exception.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> Unless it didn't exist in a previous version of ant

Appears that is the case, I should upgrade :)

Perhaps lphillips also has an old version.
0
 

Author Comment

by:lphillips120898
Comment Utility
I have version 1.5.  I'm going to try and see if I can find out if this is a new feature with 1.6 before I upgrade.

objects - I tried using the del action, but couldn't get it to delete directories.  If you have any insight on what the syntax might be please feel free to share!

grim_toaster - you're right, I did have the tag in the wrong place.  I corrected it, but still get the same results.

Thanks,

Lisa
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:lphillips120898
Comment Utility
Okay, I have confirmed that "rmdir" was not in ant version 1.5, so I upgraded to 1.6.2.  Now I have another issue.  Here is the error:

*********** ERROR ***********
 [taskdef] Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.

BUILD FAILED
C:\ccBuild\ANT_vob\Ant\Build\FTPBuildFiles.xml:54: Could not create task or type of type: if.

Ant could not find the task or a class this task relies upon.
************ END ERROR **********************

I'm guessing this is because this task is dependent on optional/additional libraries.  In the past I was using NetComponents-1.3.8a, but apparently this has been replaced by commons-net-1.2.2.  Look at the bottom of this page to see where I get this assumption:  http://jakarta.apache.org/commons/net/

I tried using the NetComponents-1.3.8a with the new version of ant, but figured it didn't work with it since I got that error.

So I assume that I can download this component and I will be okay.  Newer version of Ant and newer version of net component.  The problem is I can't find where to download it.  If you look on the components page (http://jakarta.apache.org/commons/components.html) it list all the components.  If you click on the individual ones you they have links to download the component, but the net component doesn't have a download link.

Can anyone shed some light on where I might get this - or better yet... is this what I need and if not please point me to what I do need to get FTP in ant working.

Thanks,

Lisa

0
 

Author Comment

by:lphillips120898
Comment Utility
Never mind... I figured it out.  I didn't have it on the path.
0
 

Author Comment

by:lphillips120898
Comment Utility
the rmdir is now working.... is there a way I assign the original amount of points?  I bumped them up when I couldn't figure out how to get the ftp working again, but then I figured it out.

Let me know,

Lisa
0
 

Author Comment

by:lphillips120898
Comment Utility
I want to keep this question open with the new point value of 250, I've run into some issues still trying to get the rmdir working, plus delete is not working the way it was before.

My first question is... in the documentation for 1.5 did not have the "rmdir" option for the ftp tag, but 1.6 does.  What I don't understand though is that you still have to download a third party package/jar for the ftp portion of ant to work.  So is it really the ant version that matters or the commons-net version that matters?

Anyway, at this point I have the following error when I try to remove or delete a directory.

***** ERROR ********
FTPFiles:
      [ftp] deleting files

BUILD FAILED
C:\ccBuild\ANT_vob\Ant\Build\FTPSECommonFiles.xml:47: The following error occurred while executing this line:
java.lang.NoClassDefFoundError: org/apache/oro/text/regex/MalformedPatternException
*****************

I found the following on Google from someone that was getting the same error message:
**
Solved. I download "jakarta-oro-[version].jar ". And its working.
**

I tried to find this jar, but I don't know what I should be putting the [version] section.  Does anyone have a clue?  I'm using  commons-net-1.2.2 for the additional component needed for using FTP in Ant.





0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
Comment Utility
> So is it really the ant version that matters or the commons-net version that matters?

ant

> I tried to find this jar, but I don't know what I should be putting the [version] section.  Does anyone have a clue?

http://jakarta.apache.org/oro/
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now