US>To leave the while statement in the TeraTerm macro with the if statement according to the conditions

Asked 2 years ago, Updated 2 years ago, 93 views

This is a question about how TeraTerm works with macros.

I'd like to create a system where the show commands are repeated every few seconds on While, and when Enter is pressed, it will fall out, but can I use If and Wait to do something about it?

In the image, when waiting for one # on Wait, # is displayed twice by pressing Enter, so if two # are followed in the If statement, would it be difficult to break?

;Repeat the command
cnt = 1
while cnt

sendln 'show log | grep up'

wait'#'

sendln 'show log | grep down'

wait'#'

yesnobox 'One more time? 'Message'

if result = 0 then
    cnt = cnt-1
endif

endwhile

mpause 5000

Currently, I don't know how to do it, and as mentioned above, I use yesnobox.
The equipment uses YAMAHA's FWX-120

If there is any way, please take care of me.

teraterm

2022-09-30 17:38

1 Answers

Wait a few seconds mpause to replace mtimeout and Can I wait while waiting for interrupt input by combining cvln ?

The code below is looped indefinitely on linux, repeating arbitrary processing (ping and sleep in this case) and waiting for 3 seconds.
check_inputWait up to 3 seconds each time a label is called, and if only blank characters (spaces or newline characters) are entered during that time, the regular expression is hit and the macro ends with exit.

while1
  sendln'ping 127.0.0.1-c2-i 0.5'; arbitrary action
  wait'#'$';wait for processing to complete
  call check_input

  sendln ssleep1 ;;any action 2
  wait'#'$';wait for processing to complete
  call check_input
endwhile

; Check input while sleeping
—check_input
  timeout = 3; set the timeout to 3 seconds
  recvln;Input check while sleeping until timeout
  if result = 1 then; something entered
    strmatch inputstr'.+[$#]\s*$'; only blank characters (space or newline characters) after $ or #
    if result=1 then; matches the above regular expression
      exit; macro termination
    endif
  endif
  timeout = 0; returns the timeout to infinity (initial value)
  return;return to caller


2022-09-30 17:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.