ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "O'Hara, Patrick" <patrick.oh...@workscape.com>
Subject Trying FTP Again
Date Tue, 24 Jul 2001 19:23:41 GMT
I have the following test build file:
<project name="TestLoop" default="ftp" basedir=".">
  <taskdef name="ftp"
classname="org.apache.tools.ant.taskdefs.optional.net.FTP"/>
	
<!--====================================================================-->
    <!-- These properties are set in the calling ant project
-->
	<!-- Note that the properties set there override these values
-->
	
<!--====================================================================-->
	<property name="FTPSERVER" value="ftp.someserver.com"/>
	<property name="FTPREMOTEDIR" value="/pub"/>
	<property name="FTPUSERNAME" value="annonymous"/>
	<property name="FTPPASSWORD" value="me@mydomain.com"/>
	<property name="FTPFILESEPARATOR" value="\\"/>
	<property name="FTPVERBOSE" value="true"/>
	<property name="FTPLOCALDIR" value="."/>
	<property name="FTPFILEPATTERN" value="*.DAT"/>

	<property name="YESTERDAYDIR" value=".."/>
	<property name="LOGFILE" value="ftplog.txt"/>
	<property name="LOGFILEARCHIVE" value="ftplog.old"/>
	<property name="ZIPFILE" value="myArchive.zip"/>

	<target name="transfer">
		<echo message="Sending Files"/>

		  <ftp server="${FTPSERVER}"
		       remotedir="${FTPREMOTEDIR}"
		       userid="${FTPUSERNAME}"
		       password="${FTPPASSWORD}"
		       separator="${FTPFILESEPARATOR}"
		       verbose="${FTPVERBOSE}">
		    <fileset dir="${FTPLOCALDIR}">
		      <include name="*.DAT" />
		    </fileset>
		  </ftp>

		<echo message="Archiving Files"/>
		  <delete>
		    <fileset dir="${YESTERDAYDIR}" includes="*.DAT" />
		  </delete>
		  
		  <move file="${LOGFILE}" tofile="${LOGFILEARCHIVE}"/>
		    
		  <zip zipfile="${ZIPFILE}">
			<fileset dir="${FTPLOCALDIR}">
				<include name="*.DAT" />
				<include name="*.txt" />
			</fileset>
		  </zip>
		  
		  <move todir="${YESTERDAYDIR}">
		    <fileset dir="${FTPLOCALDIR}">
		      <include name="*.DAT" />
		      <include name="*.txt" />
      	    </fileset>
		  </move>
	</target>

  <target name="checkFTPfailure">
    <available file="${ZIPFILE}" property="ftp.ok"/>
  </target>

  <target name="ftpLoop" depends="checkFTPfailure" unless="ftp.ok">
    <antcall target="transfer"/>
    <antcall target="ftpLoop2"/>
  </target>

  <target name="ftpLoop2" depends="checkFTPfailure" unless="ftp.ok">
    <antcall target="transfer"/>
    <antcall target="ftpLoop"/>
  </target>

  <target name="ftp" depends="ftpLoop"/>
</project>

I get the following output when running on a windows 2K Machine:
C:\ant\looptest>ant
Buildfile: build.xml

checkFTPfailure:

ftpLoop:

transfer:
     [echo] Sending Files

BUILD FAILED

C:\ant\looptest\build.xml:30: error during FTP transfer:
java.net.UnknownHostExc
eption: ftp.someserver.com

Total time: 16 seconds
C:\ant\looptest>

The idea was to continue to try the FTP task until it works.  We have a
cusotmer who has a finicky FTP server.  Sometimes it works and sometime it
don't.  As you can see from the output as soon as it fails (The FTP info is
faked so it will not work), Ant exits.  I have also tried making the FTP
portion a different build file (FTP.xml) and using the Ant task to call it.
I get the same result.  What I want is to keep trying until the ftp works.
If this is not possible, that's OK, I just need to know.


Patrick O'Hara
Workscape, Inc
N17 W24222 Riverwood Pl
Waukesha, WI 53188-1162
262-408-3849
262-408-3840 Fax
patrick.ohara@workscape.com


Mime
View raw message