【问题标题】:Perl reading STDIN via inetd on windows error "Bad file descriptor"Perl 通过 inetd 在 Windows 错误“错误文件描述符”上读取 STDIN
【发布时间】:2014-04-29 21:02:24
【问题描述】:

我在 Windows 上通过 Cygwin 配置了 inetd 并作为服务启动。

脚本:

use strict;
use warnings;

use IO::Socket;
use IO::Handle;
use IO::File;
use IO::Select;

print "input something\n";
STDOUT-> autoflush (1);

my $data = <STDIN> || die "(Failed reading STDIN) $^E (Error) $! (End)\n";

在命令行上:

telnet localhost <port>

它立即失败:

(Failed reading STDIN) The parameter is incorrect (Error) Bad file descriptor (End)

我一直在搜索整个谷歌,但找不到解决方案。 有人能解释一下吗?

赞赏!


更新: 感谢您的回复,我知道 IO::Socket 不会创建 Telent 服务器,但是通过设置 cygwin inetd,它就变成了一个。 Telnet 到端口 Works 并调用 inetd.conf 中的脚本。 STDOUT 也有效。唯一不起作用的是标准输入。我有一个供人们提交命令的工具,该工具通过端口作为 STDIN 将 coomands 发送到 inetd 服务器。相同的机制适用于所有 unix,如 platform、solaris、hp、linux、aix。只是不在窗户上...

我不明白的一点是,为什么 STDIN 是关闭的,我们有什么方法可以调试吗?提前致谢!

【问题讨论】:

  • 让我们忘记那个脚本,你到底想做什么?(另外,当到达流的末尾时,readline 运算符可以返回undef。如果STDIN 已关闭,这是意料之中的。关闭 STDIN 对服务/守护进程来说是有意义的。仅使用 IO::Socket 不会神奇地使您的脚本成为 telnet 服务器。
  • @amon,不,但 inetd 可以。

标签: windows perl stdin inetd


【解决方案1】:

这似乎是 Cygwin 和从 ClearCase VOB 调用 Perl 的错误。 供将来参考:我在 Cygwin 中编译了 perl,并从 inetd 脚本中调用它。据我所知,一切正常。

【讨论】:

    猜你喜欢
    • 2010-11-06
    • 2015-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多