Search code examples
antapache-commons-net

Ant telnet is hanging on a simple task


<?xml version="1.0" ?>
<project name="test" default="root">
    <target name="telnet">
        <telnet server="10.1.1.1">
            <read>login:</read>
            <write>root</write>
            <read>password:</read>
            <write>${PASSWORD}</write>
            <read>#</read>
            <write>ls</write>
            <read>#</read>
        </telnet>
    </target>
</project>

That is the code I have in a build.xml file. When I run ant (version 1.8, in bash) (I have downloaded and copied over the jars for commons-net-2.0 and jakarta-oro-2.0.8 already), this is the output I get:

Buildfile: /home/sagar/build.xml

telnet:

and then it just sits there. When I do a "who" on my server, I can see "System" waiting on login. But there is no progress after this. I can telnet into the server using normal telnet means (putty, bash, etc).

I even tried the full telnet command instead of read/write:

<telnet server="10.1.1.1" userid="root" password="root">

Any help is much appreciated!

Note: JRE 1.5, Ant 1.8, commons-net version 2.0, jakarta version 2.0.8


Solution

  • Figured it out. For anyone else who has this issue:

    Ant 1.8.0 does not seem to work with commons-net-telnet. Not sure why, but if you can go down to version 1.7, it will work.

    6 hours of head banging and frustration later, it is an undocumented version issue. Great! >: