Solved

Ant using FTP action to remove a directory

Posted on 2004-08-04
9
2,277 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
ID: 11721879
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
ID: 11723614
-->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
ID: 11723804
> 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
ID: 11725677
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:lphillips120898
ID: 11727186
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
ID: 11727450
Never mind... I figured it out.  I didn't have it on the path.
0
 

Author Comment

by:lphillips120898
ID: 11727769
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
ID: 11730761
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
ID: 11731318
> 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

911 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

18 Experts available now in Live!

Get 1:1 Help Now