• Support
  • Articles
  • Resources
  • Products

How to exit macro if encountered error during execution

Moderator: boris

2 postsPage 1 of 1

praveen2182
Newbie

Posts:
1
Joined: Tue Nov 15, 2016 7:38 am
by praveen2182 » Tue Nov 15, 2016 7:46 am
Hi,

I am very new to tera term macro usage. I have created a small script which will login to a server.
It is working correctly.

To test the negative case, I provided a dummy IP address which can not be connected.
Macro gives error link "macro first use connect macro error"

So, I am trying to find a way when ever I encountered this error, Macro is killed and an event is logged to windows log.

Any suggestions?
Trevor
Guru

Posts:
467
Joined: Wed Jul 26, 2006 8:47 am
by Trevor » Thu Nov 17, 2016 9:00 pm
Lots of ways. Here are 2 examples.

Code: Select all

  1. logopen "logfile.txt"
  2. connect "myserver:23 /nossh"
  3. if result != 2 goto error
  4.   .
  5.   .
  6.   .
  7.  
  8. goto the_end
  9. :error
  10. logwrite "connection failed"
  11. messagebox "connection failed" "Error"
  12. :the_end
  13. ; Any cleanup before exit goes here
  14. logclose
  15.  

or

Code: Select all

  1. logopen "logfile.txt"
  2. connect "myserver:23 /nossh"
  3. if result != 2 then
  4.     logwrite "connection failed"
  5.     logclose
  6.     end
  7. endif
  8.  .
  9.  .
  10.  .
  11. logclose
Display posts from previous:
Sort by:

2 postsPage 1 of 1

Users browsing this forum: No registered users
cron