Reputation: 30154
I'm trying to FTP a file to a server where the password contains an ampersand (&) via ANT The following ANT target:
<target name="upload_zip">
<ftp server="myhost.net"
userid="myusername"
password="topsecret&"
port="21"
remotedir="/public_html"
passive="yes"
binary="yes">
<fileset dir=".">
<include name="${updatefile}" />
</fileset>
</ftp>
</target>
Fails with this message:
error during FTP transfer: java.net.SocketException: Permission denied: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at ... // really long stack trace
It looks like the authentication isn't successful. If I don't escape the ampersand, then my build file is not well formed. Am I escaping the ampersand correctly or doing something wrong?
Upvotes: 1
Views: 840
Reputation: 78105
I don't think there's an obvious problem with the method you are using - the entity should be translated correctly.
To diagnose automated ftp it's probably best to try a similar (or identical!) transfer manually first. Usually that will reveal any external issues with connection credentials or permissions in the target file system.
If a manual transfer works, then the next step would be to 'spot the difference' between the manual transfer and the Ant-driven one.
A stack trace for an ftp problem is probably indicative of a pre-connect issue - once you have a connection, you'll instead see an FTP error message, e.g.:
That would probably indicate a problem with the login-password combination.
If the server is down you'll get a trace with something like:
It seems though in your case it was a problem with an intermediate proxy. For future readers, this resource may help in diagnosing passive ftp through firewall issues.
Failing all that, running Ant in verbose (-v
) or diagnostic (-diagnostics
) modes to see the innards of what Ant is doing may also give a clue.
Upvotes: 1