OSのtelnetを使用して、telnetで返信されているプロンプトをキャプチャするにはどうすればいいですか??このグルーヴィーな1ライナーは、プロンプトをキャプチャしません。これはPress Return to continue:
です。GroovyまたはJavaを使用してtelnetプロンプトをキャプチャするにはどうすればよいですか?
私は、これがtelnetの "line turnaround prompt"と呼ばれていると思います。
groovysh:
[email protected]:~$
[email protected]:~$ groovysh
Groovy Shell (1.8.6, JVM: 1.8.0_72)
Type 'help' or '\h' for help.
--------------------------------------------------------------------------------------------------------------------------------------
groovy:000> 'telnet rainmaker.wunderground.com 3000'.execute().inputStream.eachLine { line -> println line }
Trying 38.102.137.140...
Connected to rainmaker.wunderground.com.
Escape character is '^]'.
------------------------------------------------------------------------------
* Welcome to THE WEATHER UNDERGROUND telnet service! *
------------------------------------------------------------------------------
* *
* National Weather Service information provided by Alden Electronics, Inc. *
* and updated each minute as reports come in over our data feed. *
* *
* **Note: If you cannot get past this opening screen, you must use a *
* different version of the "telnet" program--some of the ones for IBM *
* compatible PC's have a bug that prevents proper connection. *
* *
* comments: [email protected] *
------------------------------------------------------------------------------
プロンプト、Press Return to continue:
は、省略されています。
JavaがProcessBuilder
を使用してOSのtelnetアプリケーションを起動するという根本的な問題点があります。しかし、上記のように、すべての出力がキャプチャされるわけではありません。プロンプトが表示されると、最後の行は省略されます。
私がApache telnetなどのtelnetライブラリを使用していないのは、Apache telnetがOSのtelnetと異なるためです(図参照)。はい、図書館はありますが、まったく同じではありません。
フルラインではなく、それぞれの文字を読みますか?
も参照してください。
https://stackoverflow.com/a/36405986/262852
https://superuser.com/a/1061649/55747
https://stackoverflow.com/a/36451474/262852
私はあなたがなぜtelnetライブラリが存在するかを発見したと思います –