Discourse-setup 使用 netcat 与非法选项组合?

正在使用 Centos 7 上的标准 discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub 安装过程,但是:

使用 nc 测试端口 80 和 443 上的网络连接如下:

    echo -e "HTTP/1.1 200 OK\n\n $VERIFY" | nc -w 4 -l -p $PORT >/dev/null 2>&1 &
    if curl --proto =http -s $HOST:$PORT --connect-timeout 3 | grep $VERIFY >/dev/null 2>&1; then
:

但是 nc 失败并显示:

nc: cannot use -p and -l

导致设置脚本报告这些端口不可用。

man nc 说:

     -l      Listen for an incoming connection rather than initiating a connection to a remote host.  Cannot be used together with any of the options -psxz.  Additionally, any timeouts specified
             with the -w option are ignored.

这可能是 nc 版本问题,我看到 nc linux command man page 没有说这两个选项有任何冲突。我的 netcat 可以监听,但只能使用

nc -w 4 -l <IP 地址> <端口号>

无法让 netcat 告诉我它的版本号 :confused:

好的,所以……有 netcat-traditional 和 netcat-openbsd,而 centos 自带前者,而 discourse-setup 需要后者。试图找到一种方法在 centos 上安装 netcat-openbsd,这似乎不是一件简单的事……

长话短说:
yum remove netcat
yum install nmap-ncat

2 个赞

这就是为什么推荐 Ubuntu 的原因。\n\n但是有两个 netcat 有多烦人?而且你的默认 netcat 似乎特别难用。\n\n很高兴你弄明白了!

1 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.