Ant telnet挂在一个简单的任务上

发布于 2024-08-30 19:34:00 字数 1052 浏览 2 评论 0原文

<?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>

这是我在 build.xml 文件中的代码。当我运行 ant (版本 1.8,在 bash 中)时(我已经下载并复制了 commons-net-2.0 和 jakarta-oro-2.0.8 的 jars),这是我得到的输出:

Buildfile: /home/sagar/build.xml

telnet:

然后它就坐在那里。当我在服务器上执行“who”操作时,我可以看到“系统”正在等待登录。但这之后就没有任何进展了。我可以使用普通的 telnet 方式(putty、bash 等)远程登录到服务器。

我什至尝试了完整的 telnet 命令而不是读/写:

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

非常感谢任何帮助!

注意:JRE 1.5、Ant 1.8、commons-net 版本 2.0、jakarta 版本 2.0.8

<?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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木森分化 2024-09-06 19:34:00

想通了。对于遇到此问题的其他人:

Ant 1.8.0 似乎不适用于 commons-net-telnet。不知道为什么,但如果你可以降到 1.7 版本,它就可以工作。

6个小时的头撞和挫败感过后,这是一个未记录的版本问题。伟大的! >:

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! >:

你是暖光i 2024-09-06 19:34:00

不是 Ant 专家(我在黑暗面使用 Nant),但查看 telnet 任务,看起来有一个名为 initialCR 的属性,它在登录后发送回车符 - 默认值似乎是'不'。

我的想法是用户名/密码尚未提交,即它只是等待按下“伪回车键”。

http://ant.apache.org/manual/Tasks/telnet.html

希望这有帮助

Not an expert in Ant (I use Nant on the Dark Side) but looking at the telnet task it looks like there is an attribute called initialCR which sends a carriage return after login - the default value appears to be 'no'.

My thinking is that the username/password has not been submitted, i.e. its just waiting for the "pseudo enter key" to be pressed.

http://ant.apache.org/manual/Tasks/telnet.html

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文