• Support
  • Articles
  • Resources
  • Products

Any automated code to replace Mpause?

Moderator: boris

4 postsPage 1 of 1

Mokan
Newbie

Posts:
4
Joined: Mon Jun 19, 2017 2:14 am
by Mokan » Mon Jun 19, 2017 2:19 am

Code: Select all

  1.  
  2. ; ***Macro Template to collect Router log****************
  3.  
  4. ; Get current directory
  5. getdir curdir
  6. groupmatchstr1=curdir
  7. groupmatchstr2="\Logs"
  8. strjoin strvar "" 2
  9. changedir strvar
  10. setdir strvar
  11.  
  12. CommandPrompt = '#'
  13. inputbox 'Please enter ZoneID:' 'Zone ID'
  14. ZoneID = inputstr
  15. ;inputbox 'Please enter SiteID:' 'Site ID'
  16. ;SiteID = inputstr
  17. SiteID = ''
  18. inputbox 'Please enter Router name with Router ID:' 'Router Name'
  19. RouterName = inputstr
  20. toupper RouterName RouterName
  21.  
  22. groupmatchstr1=ZoneID
  23. groupmatchstr2=SiteID
  24. groupmatchstr3=RouterName
  25. groupmatchstr4=".log"
  26. strjoin logfile "" 4
  27. ;logfile=strvar
  28.  
  29. groupmatchstr1= logfile
  30. groupmatchstr2= ".tmp"
  31. strjoin tmp_file "" 2
  32. ;tmp_file = strvar
  33.  
  34. ;start logging
  35. logopen logfile 0 0
  36. gettime curtime "------------------------------------%Y-%m-%d %H:%M:%S----------------------------------"
  37. logwrite curtime
  38.  
  39. ;setsync 0
  40.  
  41. sendln
  42.  
  43. wait CommandPrompt
  44. sendln 'set sl=n'
  45.  
  46. wait CommandPrompt
  47. flushrecv
  48. sendln 'sh date'
  49.  
  50. wait CommandPrompt
  51. flushrecv
  52. sendln 'sh timezone'
  53.  
  54. wait CommandPrompt
  55. flushrecv
  56. sendln 'sh ' 'sysinfo'
  57.  
  58. wait CommandPrompt
  59. flushrecv
  60. sendln 'sh ' '-' 'ip allroute'
  61.  
  62. mpause 500
  63. wait CommandPrompt
  64. flushrecv
  65. sendln 'sh ' '-' 'ntp status'
  66.  
  67. wait CommandPrompt
  68. flushrecv
  69. sendln 'sh ' '-' 'sys sm'
  70.  
  71. mpause 500
  72. wait CommandPrompt
  73. flushrecv
  74. sendln 'sh version'
  75.  
  76. pause 5
  77. wait CommandPrompt
  78. sendln 'exit'
  79.  
  80. logclose
  81.  


Above is an example of macro to collect logs from a router. Any idea how to code to make sure that the a command runs completely from one command to another command without using "mpause". Any idea how do i automate it??
Trevor
Guru

Posts:
483
Joined: Wed Jul 26, 2006 8:47 am
by Trevor » Tue Jun 20, 2017 11:40 am
Have you tried just removing the "mpause" lines? If so what does not work when you do?
Mokan
Newbie

Posts:
4
Joined: Mon Jun 19, 2017 2:14 am
by Mokan » Wed Jun 21, 2017 1:19 am
Trevor wrote:Have you tried just removing the "mpause" lines? If so what does not work when you do?

The reason i included mpause is that to allow the command before to run completely. Is there any way besides using mpause to get the commands completely executed before jumping into another command while running through macro.
Trevor
Guru

Posts:
483
Joined: Wed Jul 26, 2006 8:47 am
by Trevor » Thu Jun 22, 2017 9:00 am
But you are waiting for the command prompt after the command so therefore the mpause should not be needed i.e. the command prompt should only appear after the command has completed. Hence my previous question.

The wait for command prompt should really have a timeout and detect when a timeout occurs. I would make it a function like this:

Code: Select all

  1. :wait_for_command_prompt
  2.     timeout = 10
  3.     waitln '#'
  4.     if result == 0 then
  5.         messagebox 'timeout waiting for command prompt' 'Error'
  6.         end
  7.     endif
  8.     flushrecv
  9. return

And then instead of

Code: Select all

  1. wait CommandPrompt
use

Code: Select all

  1. call wait_for_command_prompt


Then if you do need a delay you have just one place to put in (in the function).
Display posts from previous:
Sort by:

4 postsPage 1 of 1

Users browsing this forum: No registered users
cron