在teraterm中等待某个词

时间:2015-01-28 15:18:01

标签: scripting macros teraterm

我现在正在做一些teraterm脚本,我想等待某个单词(在一些大字符串中),如果找到该单词然后执行命令,如果没有找到执行另一个命令。我试着使用wait和if_else,但它没有用,请帮助。

3 个答案:

答案 0 :(得分:2)

根据您的问题,我相信您可以在不使用 if_else 的情况下获得正确的解决方案。我刚刚参与了一周前的teraterm脚本编写,到目前为止我的经验和知识都在COM端口通信中。例如,我将显示一个要登录的代码片段:

;Set the COM port
connect '/C=5'

;Set Baud rate
setbaud 9600

;Set the display
showtt 1

;Set the timeout in seconds and result
timeout = 10
result = 1

;Set the username and password's prompt and value
UsernamePrompt='login:'
PasswordPrompt='Password:'
Username='admin'
Password='mypasword'

;Wait for the UsernamePrompt
wait UsernamePrompt
;If timeout occurs, result will be 0, else, result will be 1
if result = 0 goto Error
if result = 1 goto Ok

:Error
;Do the processing here if timeout occurs

:Ok
;Do the processing here if UsernamePrompt is received
sendln Username

我相信这会对你有所帮助。你可以去这里:https://ttssh2.osdn.jp/manual/en/macro/command/wait.html 了解超时等待

度过愉快的一天。

答案 1 :(得分:1)

与我的实验一样,我发现waitln在处理大字符串时仍然可用。我使用waitln等待一个字符串足够长(超过两个单词)并使用if ... then ... endif。

答案 2 :(得分:0)

检查宏的超时时间。明确提供一些超时值

相关问题