Telnet xinetd スクリプトは出力をエコーし​​ません。

Telnet xinetd スクリプトは出力をエコーし​​ません。

xinetdをインストールしてスクリプトを作成しました。

#!/bin/bash
echo "Some text"
touch /home/somefile

以下のサービス設定があり、/etc/xinetd.d/デフォルトで設定されたポートからlocalhostに接続すると機能します。その理由は次のとおりです。somefileサービスに接続すると、touchコマンドでファイルが生成されます。 Telnetを使用して接続します。

telnet localhost someport

私が理解していないのは、Telnetが「Some text」という文字列を出力しないことです。これを行うにはどうすればよいですか?

これは、/etc/xinetd.d/にあるxinetdサービス構成ファイルです。


# This is the configuration for the tcp/stream echo service.

service my_service_name #not in /etc/services
{
# This is for quick on or off of the service
        disable         = no

# The next attributes are mandatory for all services
        id              = my_custom_id
        type            = UNLISTED
        wait            = yes
        socket_type     = stream
        protocol        = tcp

# External services must fill out the following
        user            = root
#       group           =
        server          = /usr/bin/program_name_here
#       server_args     =

# External services not listed in /etc/services must fill out the next one
        port            = 60001
}

ベストアンサー1

waitに変更すると、no問題が解決する可能性があります。マニュアルページから:

値がyesの場合、サービスはシングルスレッドです。これは、xinetdがサーバーを起動し、サーバーがシャットダウンし、サーバーソフトウェアが接続を受け入れるまでサービス要求の処理を停止することを意味します。

重要なのは、waitがyesに設定されている場合、サーバーソフトウェアは接続を受け入れる必要がありますが、スクリプトはそうしないことです。

おすすめ記事