• Support
  • Articles
  • Resources
  • Products

Several observations while using Tera Term for routine task automation

Moderator: boris

5 postsPage 1 of 1

boris
Moderator, LogMeTT and TTLEditor developer

Posts:
1577
Joined: Sat Jan 08, 2005 2:52 pm
by boris » Fri Dec 02, 2016 8:43 pm
Yesterday I was tasked to perform quick audit of two particular configuration settings on 300+ devices and I was given about 3 hours to complete the task. I obtained the list of all device hostnames and put together the macro script pasted below to automate the task.

While I was able to complete the job, it took me much longer that I expected and I want to bring to Tera Term project team's attention the issues that I experienced and had to troubleshoot as well as few observations:

- Since the task supposed to take quite some time, my intention was to start it and continue working on something else. Unfortunately I was not able to accomplish this because every time SSH Authentication window popups up, it steals the focus from active application, i.e. I was not able to write emails and do other work. Neither setting showtt 0, nor minimizing Tera Term window changes this annoying behavior.

- If SSH login fails due to incorrect credentials testlink command is not able to identify it. The macro goes into waiting loop and there is no indication of what happened. Only after terminating the macro and closing Tera Term main window the error message appears saying that user credentials were invalid. I expect the same will happen if authentication method (password, challenge, etc) is incorrect, but I have not tested that. There should be a better way to handle such scenarios.

- After failure to log in as described in the previous item I tried to pause and resume macro. This unexpectedly caused new Tera Term window to open and macro script continued running there. I was logging the session and to continue logging under this behavior I had to move logopen and logclose commands inside the loop.

- /nosecurity argument of connect command (which is by the way not documented in Help) suppresses the warning popup, however it does not add the signature to ssh_known_hosts file. Not sure if this is a bug or as per design. In either case this is not the behavior user may expect.

- There was number of times when the 1st sendln command after establishing the connection would not appear on the screen and in the log file, nevertheless it was preceded by wait for prompt command. Considering that I was not able to do anything else due to the 1st issue in this list and that I used setsync command in my macro, it would be interesting to know if I reached the capacity limits of the application.

Here is my Macro script:

Code: Select all

  1. timeout = 2
  2. Logfile = 'C:\Temp\logfile.txt' ; log file name
  3. fileopen fhandle 'C:\Temp\ip_addresses.txt' 0   ; plain text file with one hostname (or IP) per line
  4. while 1
  5.     filereadln fhandle ip_address
  6.     if result=1 then
  7.         break
  8.     endif
  9.     sprintf2 con_str '%s:22 /ssh /2 /nosecuritywarning /auth=password /user=username /passwd=thepassword' ip_address
  10.     connect con_str
  11.     testlink
  12.     if result = 2 then
  13.      setsync 1
  14.      logopen Logfile 0 1 0 0
  15.      wait '#'
  16.       sendln 'show version'
  17.       wait '#'
  18.       sendln 'show config-sync'
  19.       sendln
  20.       wait '#'    
  21.      logclose
  22.      disconnect 0
  23.      do
  24.        testlink
  25.        pause 1  
  26.      loop while result = 2   
  27.     else
  28.       messagebox "Cannot connect to the host. Click OK to Continue." "Connection Error"
  29.     endif
  30. endwhile
  31. fileclose fhandle


I am running Tera Term 4.93 on Windows 7 Professional.
Thanks.
Best regards,
Boris
Yutaka Hirata
TeraTerm Developer

Posts:
596
Joined: Wed Jan 12, 2005 2:35 pm
by Yutaka Hirata » Tue Dec 20, 2016 4:08 pm
Hi Boris,

Thank you for your feedback.
I have registered your suggestion as the ticket#36888 in the following:

https://osdn.net/ticket/browse.php?grou ... &tid=36888

We will consider whether your suggestion is supported in the future.
Since I may ask you questions, I would appreciate your help
at that time.

Thanks.
Best regards, Yutaka Hirata
(yutakakn at gmail.com)
http://hp.vector.co.jp/authors/VA013320/
Yutaka Hirata
TeraTerm Developer

Posts:
596
Joined: Wed Jan 12, 2005 2:35 pm
by Yutaka Hirata » Wed Dec 21, 2016 2:36 pm
Hi Boris,

I have some questions for your suggestion.

- After failure to log in as described in the previous item I tried to pause and resume macro. This unexpectedly caused new Tera Term window to open and macro script continued running there. I was logging the session and to continue logging under this behavior I had to move logopen and logclose commands inside the loop.


Unfortunately, I do not understand what you say.
Where is your problem?

- /nosecurity argument of connect command (which is by the way not documented in Help) suppresses the warning popup, however it does not add the signature to ssh_known_hosts file. Not sure if this is a bug or as per design. In either case this is not the behavior user may expect.


The hidden option is described in help document. Please refer to below page.
http://ttssh2.osdn.jp/manual/en/commandline/ttssh.html

- There was number of times when the 1st sendln command after establishing the connection would not appear on the screen and in the log file, nevertheless it was preceded by wait for prompt command. Considering that I was not able to do anything else due to the 1st issue in this list and that I used setsync command in my macro, it would be interesting to know if I reached the capacity limits of the application.


Unfortunately, I do not understand what you say.
Where is your problem?

Please tell me when you have time.
Best regards, Yutaka Hirata
(yutakakn at gmail.com)
http://hp.vector.co.jp/authors/VA013320/
boris
Moderator, LogMeTT and TTLEditor developer

Posts:
1577
Joined: Sat Jan 08, 2005 2:52 pm
by boris » Thu Dec 22, 2016 3:38 am
Hi Yutaka,

I will need to reproduce the 1st and the 3rd items to provide you with more details. Unfortunately I will be able to do this only after January 10th, when I return to work from my vacation.

As for /nosecuritywarning - I meant it is not documented in Connect command description here: http://ttssh2.osdn.jp/manual/en/macro/c ... nnect.html
Thanks.
Best regards,
Boris
ludgert
Newbie

Posts:
2
Joined: Wed Aug 24, 2016 10:33 am
by ludgert » Mon Feb 06, 2017 3:21 pm
Actually I use scripts for handling many network components (like switches, firewalls, loadbalancer etc) for many tasks like configuration checks, configuration changes and so on. I have made the same experiences especially the points 1 (focus) and 2 (testlink). How can I get the status from the ticket 36888 ? Thanks.

boris wrote:Yesterday I was tasked to perform quick audit of two particular configuration settings on 300+ devices and I was given about 3 hours to complete the task. I obtained the list of all device hostnames and put together the macro script pasted below to automate the task.

While I was able to complete the job, it took me much longer that I expected and I want to bring to Tera Term project team's attention the issues that I experienced and had to troubleshoot as well as few observations:

- Since the task supposed to take quite some time, my intention was to start it and continue working on something else. Unfortunately I was not able to accomplish this because every time SSH Authentication window popups up, it steals the focus from active application, i.e. I was not able to write emails and do other work. Neither setting showtt 0, nor minimizing Tera Term window changes this annoying behavior.

- If SSH login fails due to incorrect credentials testlink command is not able to identify it. The macro goes into waiting loop and there is no indication of what happened. Only after terminating the macro and closing Tera Term main window the error message appears saying that user credentials were invalid. I expect the same will happen if authentication method (password, challenge, etc) is incorrect, but I have not tested that. There should be a better way to handle such scenarios.

- After failure to log in as described in the previous item I tried to pause and resume macro. This unexpectedly caused new Tera Term window to open and macro script continued running there. I was logging the session and to continue logging under this behavior I had to move logopen and logclose commands inside the loop.

- /nosecurity argument of connect command (which is by the way not documented in Help) suppresses the warning popup, however it does not add the signature to ssh_known_hosts file. Not sure if this is a bug or as per design. In either case this is not the behavior user may expect.

- There was number of times when the 1st sendln command after establishing the connection would not appear on the screen and in the log file, nevertheless it was preceded by wait for prompt command. Considering that I was not able to do anything else due to the 1st issue in this list and that I used setsync command in my macro, it would be interesting to know if I reached the capacity limits of the application.

Here is my Macro script:

Code: Select all

  1. timeout = 2
  2. Logfile = 'C:\Temp\logfile.txt' ; log file name
  3. fileopen fhandle 'C:\Temp\ip_addresses.txt' 0   ; plain text file with one hostname (or IP) per line
  4. while 1
  5.     filereadln fhandle ip_address
  6.     if result=1 then
  7.         break
  8.     endif
  9.     sprintf2 con_str '%s:22 /ssh /2 /nosecuritywarning /auth=password /user=username /passwd=thepassword' ip_address
  10.     connect con_str
  11.     testlink
  12.     if result = 2 then
  13.      setsync 1
  14.      logopen Logfile 0 1 0 0
  15.      wait '#'
  16.       sendln 'show version'
  17.       wait '#'
  18.       sendln 'show config-sync'
  19.       sendln
  20.       wait '#'    
  21.      logclose
  22.      disconnect 0
  23.      do
  24.        testlink
  25.        pause 1  
  26.      loop while result = 2   
  27.     else
  28.       messagebox "Cannot connect to the host. Click OK to Continue." "Connection Error"
  29.     endif
  30. endwhile
  31. fileclose fhandle


I am running Tera Term 4.93 on Windows 7 Professional.
Display posts from previous:
Sort by:

5 postsPage 1 of 1

Users browsing this forum: No registered users