Home | Switchboard | Unix Administration | Red Hat | TCP/IP Networks | Neoliberalism | Toxic Managers |
May the source be with you, but remember the KISS principle ;-) Skepticism and critical thinking is not panacea, but can help to understand the world better |
News | Telnet Clients | Recommended Links | Teraterm Macros | Reference for macrolanguage | Invoking Teraterm from command line | Highlights of enhancements in latest versions |
Teraterm log and replay function | Using different backgound for different servers in Teraterm | SSH | Password-less SSH login | TTSSH | Using Pageant for authentication | |
CygTerm+ | Exceed HostExplorer | Putty | Telnet protocol | Teraterm connect command | LogMeTT | TTPMenu |
Expect | GNU Screen | Tips | Admin Horror Stories | Unix History | Humor | Etc |
Teraterm is a very important program for any Unix system administrator. So even a little time spend to study it and to adopt better configuration brings great dividends. While colors used and size of the screen necessary is highly idiosyncratic, there are still many common themes and problems for which the following tips might be useful:
TeraTerm 2019.06.15 (Ver 4.103) Changes added support for High DPI experimentally. The default setting is disabled. When DPIAware=on is set in Tera Term of teraterm.ini file, this feature is enabled. However, this is only available for Windows 10 Version 1703 or later. The font submenu is newly added, and added support for configure the. Searching for Tera Term tab manager lead to no useful results, but to do the job you want, to have multiple-terminal access via only one window with tabs, you can use Putty Connection Manager, it allows you to do this. You can find more detailed information in the following link. The command, start ttermpro.exe TTPMACRO 'Teratermmacrosmacro.ttl', will result in Tera Term attempting to connect to the host 'TTPMACRO', which likely does not exist. Thus, Tera Term prints the 'Invalid Host' error message. Based on the documentation for the ttermpro command line options (here), a command to start Tera Term with a macro is.
In the latter case you can extract the list from TERATERM.INI. They are located close to the end of the file, starting with the line [Hosts] andhave the format like that
You can extract them using egrep and then cut them at '=' to extract the DNS names of each server and then convert into connect string. Which allow you to generates as many macros as you you have defined hosts (in simplest case macro is just a one-liner with just connect command) that login to each server you administer. In the simplest form such script can be create using xargs command. Something along the lines
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
You can change the default method via Setup/SSH authentication and then selection 'use challenge/response to log in...' (or change DefaultAuthMethod=3 to DefaultAuthMethod=5 in teraterm.ini file)
That makes Teraterm behavior compatible with Putty where this authentication method is a default.
You can use Pageant for authentication
Options
Examples
Default values
Following default values are stored in the Tera Term setup file:
Notes
[1] Only if <telnet flag> is 1 (on) and <TCP port#> is 23, Tera Term starts spontaneously sending telnet commands to the host for the option negotiation when the TCP/IP connection is established. In any cases, Tera Term can respond to telnet commands sent by the host.
[2] Quote the multicast name when the name includes the space and `' character. And then, a user should put the window title in quotations by using `' character two times to include the character.
Switchboard | |||||
Latest | |||||
Past week | |||||
Past month |
So I'm attempting to consolidate what I know of the TeraTerm language into a single mega-post. If you have any knowledge that you think would be a valuable addition to this post, feel free to let me know.
Note that this is pretty much just an abridged form of the language reference tied into a somewhat cohesive format. Just because something isn't mentioned here doesn't mean it doesn't exist; check out the official language reference and search the forums to get a handle on some of TeraTerm's more advanced features. This is really not a full-fledged tutorial to take you from the very basics of computer literacy; if you have no prior programming experience this may be challenging to follow.
As a little precursor, if you happen to use Programmer's Notepad as your editor of choice, the NSIS Installer highlighting scheme matches fairly well with this scripting language. Vim users might be able to make use of this highlighting scheme (somewhat outdated, won't have latest keywords).
TeraTerm basics
So to start things off, let's deal with variables.
There are two types of variables: Strings (limited to 255 characters) , and Integers (Limited to ~ +/-2 billion) (want to go bigger?). The type is determined implicitly when the variable is created and cannot be altered afterwards.
Also, since TeraTerm 4.72, there are now arrays of both of these types (limited to 65536 indices per array)
But variables by themselves are boring. The real basis of any programming language is the if statement. However an if statement by itself is somewhat boring, so let's go a little further and also show you a wait statement:
The wait statement is one of the more or less unique features of TeraTerm. Essentially, it reads through all of the serial output that hasn't been parsed yet, and when one of the strings in its sensitivity list is found, it sets result to the index of that string and moves on. The documentation for the setsync command has a partial general overview for how TeraTerm internally works.
Note that you can also set a timeout for wait, and it will then only hold up the execution of the script for at most timeout.mtimeout seconds:
A nice counterpoint to the 'wait' command is the 'sendln' and 'send' commands. These guys do pretty much what their names suggest: they write stuff back out to the terminal (with sendln adding a newline at the end of its string). A common use that I have for the wait/sendln pair is to send a series of commands to a machine. For example, when sending a series of commands to a Linux box, it might look something like the following:
Note that the above code is somewhat ugly. If the prompt were to change (say from root@localhost to root@servername), I'd have to manually replace a bunch of lines. Since I'm lazy, the following format is much nicer:
Looping
Branching is all well and good, but eventually you will want to do something that has some repetition in it. Teraterm has several more or less standard looping constructs
I won't go into too much detail about all of these; TeraTerm probably has more looping constructs than is really healthy, but definitely keep in mind the 'for' loop, and the fact that the 'do while' loop can be done as a pre-test loop or a post-test loop. The 'break' command can also be used to escape from a loop before its condition triggers
Lastly for the basics is TeraTerm's goto command. Some people (especially those experienced with C and who have experienced the nightmares of spaghetti code) view gotos as positively evil and wish they could be nuked from every language in existence. Gotos can do just about anything, but typically not as nicely as one of the above looping structures. About the only place that gotos should really go is in error handling:
TeraTerm and regular expressions
Regular expressions are an interesting creature in and of themselves. An old and relatively well-known quote about regular expressions (regexes) goes something like this:
Quote:
Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems.
Regexes are a double-edged sword that allow you to do stuff with strings that would normally not be possible. Since I don't really want to go into all the nitty gritty, here's a link to wikipedia, as well as afairly-well-laid-out regex tutorial site. Note that TeraTerm has also posted a reference for the regex engine that they use, but that isn't really laid out for learning...
TeraTerm has several commands which use the power of regular expressions (let me know which one's I'm forgetting...):
strmatch and strreplace are both relatively normal. You put your regular expression in, and TeraTerm works its magic.
waitregex is a beast that I've seen misused in these forums time and again. In many ways, it is identical to the wait command, just with regular expression support. The large difference is with regular expression matching. Regular expression matching is what happens when a regular expression with parenthesis triggers on a string. The result inside the string is then returned (in normal regular expressions, it is returned as 1, 2, 3, etc, while with TeraTerm, they are stored in the groupmatchstr1, groupmatchstr2,...,groupmatchstr9 variables).
An example is as follows:
Let's pick the above code fragment apart bit by bit.
First we have '[0-9]+' This regex essentially grabs the largest amount of consecutive characters that fall between 0 and 9. The parenthesis '(...)' are what initiate the grouping. With the parenthesis, the string that was caught by '[0-9]+' gets stored into groupmatchstr1. If the regular expression as a whole was triggered, the result will be one and the if statement will let the str2int command work its magic. The str2int command (and its counterpart, the int2str command) do exactly what their names suggest: convert between string and integer variables.
Thus, if the 'value = 5643' was received on the terminal, this code would set returnValue to 5643
Note that waitregex only works on the first 255 characters of a line, so anything further than that and you're going to have to find another way.
File input and output
My file I/O skills are minimal at best. Anything that you'd care to offer is gladly accepted
Also, don't forget about the ability to use logging commands in some cases (check out loginfo, logopen, logclose, logstart, logpause, and logwrite)
User input and output
Most of the commands used here are described in the Miscellaneous Commands section of the TTL Command Reference.
Strings!!!
Fill this section with stuff for commands like sprintf2
Connecting to things other than serial ports and whatnot
I'm really not at all good with TeraTerm in this department. If someone else here has some wisdom to offer, feel free to drop it off here...
Any feedback is appreciated, both for my sake, and for all of the newbies out there. The main goal of this post is to be a one-stop learning reference for people who are just learning the language, as well as to facilitate the general usability of it through simple examples.
Good luck, bon apetit, hasta la vista, whatever. Just go out and make/break something...
Changelog:
10/24/2012 - Added a brief (unverified) description of arrays (I use a slightly older version of TT at work, and primarily use Linux at home currently, so I haven't had a chance to play around with these)
10/31/2012 - Added more formatting/hyperlinks and clarified a few points
Let's keep the suggestions coming!
_________________
If one of my posts helped you out, do me a favor:
Next time anyone asks you for help, go out of your way to help them.
Thanks!
You can save the host data to the file if you use Tera Term logging function.
Log to the file
You can log characters received from the host. Execute the [File] Log command to start logging.
Do in the following commands:
Input the saving file name to `File Name:'.
All host data will be written to the file if you check `Binary' option.
KANJI, CR and LF codes are converted to host character code, written to the file if you uncheck `Binary' option. However, the escape sequences are not written to the file.
The host data will append the file if you check `Append' option.
The host data will overwrite the file if you uncheck `Append' option.
To browse log files, which contain escape sequences, it is convenient to use the replay function of Tera Term. To replay a log file.
Replay the log file
Run Tera Term with command line in the following:
Tera Term analyzes the specified log file and understands the escape sequence datas. If so, the contents of log file will be displayed in Tera Term window as if the characters were received from the host. We call this function 'replay log'.
And also, you can also use 'Host:' on the [File] New connection command.
Auto indent can be disabled on pasting from clipboard
Basically, the host application can not recognize the difference between the user input and pasting from clipboard. However, when a user uses the Bracketed Paste Mode as the xterm extension, the application can recognize its difference and a user can change the behavior of pasting from clipboard.
The vim configuration is described below. The following will use xterm's bracketed paste mode to make pasting automatically enable paste mode and insert mode. Also works fine in ~/.vimrc file.
When a user pastes at the normal mode by using the above configuration, the mode will be automatically changed to the insert mode and do the paste. If this behavior is denied, use the below configuration.
Also, refer to the GNU Screen Notice.
The vim editor can automatically recognize the terminal color number, namely the 256 color supporting because the Tera Term 4.83 or later supports the Termcap String Query of xterm. So, a user must properly configure the background setting to draw the highlight color regarding the vim background color.
When the background color is the dark color(i.e, black), specify the dark setting. Also, when the background color is the bright color(i.e, white), specify the light setting.
With above setting, the vim can know the terminal background color. So, if the configuration is mistaken, the highlight color will be indistinct because the text and the background color is almost same.
If the vim automatic recognition of color is stopped, add the set t_RV= entry in the .vimrc file. However, the automatic recognition of mouse type is stopped.
Also, refer to the :help 'background' on the vim editor for details.
On the command line, or on the [File] New connection dialog box, you can specify the TCP port number (<TCP port#>) and telnet flag (<telnet flag>) for a TCP/IP connection. If these parameters are omitted in the command line, the default values are taken from the Tera Term setup file.
Only if <telnet flag> is 1 (on) and <TCP port#> is 23, Tera Term starts spontaneously sending telnet commands to the host for the option negotiation when the TCP/IP connection is established.
This particular port number for telnet, 23, can be changed by editing the TelPort line in the [Tera Term] section of setup file like the following:
You can save the host data to the file if you use Tera Term logging function.
Log to the file
You can log characters received from the host. Execute the [File] Log command to start logging.
Do in the following commands:
Input the saving file name to `File Name:'.
All host data will be written to the file if you check `Binary' option.
KANJI, CR and LF codes are converted to host character code, written to the file if you uncheck `Binary' option. However, the escape sequences are not written to the file.
The host data will append the file if you check `Append' option.
The host data will overwrite the file if you uncheck `Append' option.
To browse log files, which contain escape sequences, it is convenient to use the replay function of Tera Term. To replay a log file.
Replay the log file
Run Tera Term with command line in the following:
Tera Term analyzes the specified log file and understands the escape sequence datas. If so, the contents of log file will be displayed in Tera Term window as if the characters were received from the host. We call this function 'replay log'.
And also, you can also use 'Host:' on the [File] New connection command.
Google matched content |
Society
Groupthink :Two Party System as Polyarchy : Corruption of Regulators :Bureaucracies :Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia :Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience :Who Rules America :Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy
Quotes
War and Peace: Skeptical Finance : John Kenneth Galbraith :Talleyrand :Oscar Wilde :Otto Von Bismarck :Keynes :George Carlin :Skeptics :Propaganda : SE quotes : Language Design and Programming Quotes :Random IT-related quotes : Somerset Maugham :Marcus Aurelius :Kurt Vonnegut :Eric Hoffer :Winston Churchill :Napoleon Bonaparte :Ambrose Bierce : Bernard Shaw : Mark Twain Quotes
Bulletin:
Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis :Political Skeptic Bulletin, 2013 :Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments :Slightly Skeptical Euromaydan Chronicles, June 2014 :Greenspan legacy bulletin, 2008 :Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) :Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 :Inequality Bulletin, 2009 :Financial Humor Bulletin, 2008 :Copyleft Problems Bulletin, 2004 :Financial Humor Bulletin, 2011 :Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult :Political Skeptic Bulletin, 2011 :Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law
History:
Fifty glorious years (1950-2000): the triumph of the US computer engineering :Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds :Larry Wall :John K. Ousterhout : CTSS : Multix OSUnix History : Unix shell history :VI editor :History of pipes concept :Solaris : MS DOS : Programming Languages History :PL/1 : Simula 67 :C :History of GCC development : Scripting Languages :Perl history :OS History : Mail :DNS : SSH : CPU Instruction Sets :SPARC systems 1987-2006 :Norton Commander :Norton Utilities :Norton Ghost :Frontpage history :Malware Defense History :GNU Screen : OSS early history
Classic books:
The Peter Principle : Parkinson Law : 1984 :The Mythical Man-Month : How to Solve It by George Polya :The Art of Computer Programming :The Elements of Programming Style :The Unix Hater’s Handbook :The Jargon file :The True Believer :Programming Pearls :The Good Soldier Svejk : The Power Elite
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society :Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story :The Cuckoo's Egg :IT Slang : C++ Humor : ARE YOU A BBS ADDICT? :The Perl Purity Test :Object oriented programmers of all nations : Financial Humor :Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor :Goldman Sachs related humor :Greenspan humor : C Humor :Scripting Humor :Real Programmers Humor :Web Humor : GPL-related Humor : OFM Humor :Politically Incorrect Humor :IDS Humor : 'Linux Sucks' Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor :Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor :Networking Humor :Shell Humor :Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 :Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor :Education Humor : IBM Humor : Assembler-related Humor :VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor
The Last but not LeastTechnology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D
Copyright © 1996-2020 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) in the author free time and without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
FAIR USE NOTICEThis site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info |
Disclaimer:
The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with.We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.
Last modified:July 28, 2019