Как мне отправить только «возврат» на этот сервер te lnet:
got New York
spawn telnet rainmaker.wunderground.com
Trying 35.160.169.47...
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: jmasters@wunderground.com *
------------------------------------------------------------------------------
Press Return to continue:invalid command name ""
while executing
"[tutstack::connect "New York"]"
(file "main.tcl" line 6)
код:
package provide weather 1.0
package require Tcl 8.5
package require Expect
namespace eval ::tutstack {
}
proc ::tutstack::connect {arg1} {
puts "got $arg1"
spawn telnet rainmaker.wunderground.com
set telnet $spawn_id
expect -nocase "Press Return to continue:"
send "$arg1"
}
main:
lappend auto_path /home/thufir/NetBeansProjects/spawnTelnet/telnet/api
package require weather 1.0
[tutstack::connect "New York"]
Я пробовал вариантов на send "\r"
безуспешно.
В конечном итоге, мне бы хотелось, чтобы скрипт только частично автоматизировал ответы и оставил соединение открытым .
ожидаемый результат:
thufir@dur:~/NetBeansProjects/spawnTelnet/telnet$
thufir@dur:~/NetBeansProjects/spawnTelnet/telnet$ telnet rainmaker.wunderground.com
Trying 35.160.169.47...
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: jmasters@wunderground.com *
------------------------------------------------------------------------------
Press Return to continue:
Press Return for menu
or enter 3 letter forecast city code--
WEATHER UNDERGROUND MAIN MENU
******************************
1) U.S. forecasts and climate data
2) Canadian forecasts
3) Current weather observations
4) Ski conditions
5) Long-range forecasts
6) Latest earthquake reports
7) Severe weather
8) Hurricane advisories
9) Weather summary for the past month
10) International data
11) Marine forecasts and observations
12) Ultraviolet light forecast
X) Exit program
C) Change scrolling to screen
H) Help and information for new users
?) Answers to all your questions
Selection:
В идеале, я бы хотел, чтобы некоторые ответы были автоматизированы, но в конечном итоге я бы хотел ввести текст, который отправляется на te lnet сервер тоже - в зависимости от логи c. Но пока просто пытаюсь написать несколько ответов.
см. Также:
ожидайте - te lnet соединение