Tera Term is easily one of the most powerful free Terminal Emulation Software that I have come across and the power of it lies in its scripting language TTL. Of-course, it is not as extensive and capability rich as Perl but for a non-programmer, a browse through a single help file on TTL language is all it takes to create wonderful scripts that could make his/her life easier in maintaining huge networks.
The capabilities are limitless and if you could find better ways of enhancing the following script, please come forward and do your bit.
The purpose of the script is for terminal configuration of repetitive commands in multiple terminal enabled devices at once but sequentially without human intervention.
The other purpose of the script is to fetch terminal information from multiple terminal enabled devices at once but sequentially without human intervention.
The script is primarily designed for working with Cisco devices which can be configured using terminal emulation and which has a Command Line Interface (
With the loopback in place, type some characters into to Tera Term and see if you can see what you type; if you can, the loopback is passing (good signal up to that point) Need to jumper pins 2 (TX) and 3 (RX) on 25 pin plug/RS232 output of Lantronix box. As you look at pins they number right to left 1-13 on top,14-25 on bottom of plug. The ttl file extension is associated with the Tera Term, a free terminal emulation program for Microsoft Windows operating system. The ttl file stores macro created for automate processes in Tera Term. Tera Term will execute commands from a TTL file. Create a text file with your one command, or any number of commands, and save the file with a.TTL extension. In Tera Term click the 'Control' menu, then select 'Macro'. This will allow you to navigate to your TTL file. There are example TTL files in the Tera Term installation directory. Today I installed Tera Term 4.67 and tried the new dispstr macro function. I believe there is a bug. I found that the connect command must return a result of 2 in order for dispstr to work. Even though a result of 1 from connect is enough to link the macro to a TeraTerm console, dispstr will not display the string. Teraterm Macro How to use Tera Term for the Serial Console An RS-232 serial console allows the DNP/2486 Linux to be controlled from a terminal or a PC with a terminal emulation program attached to the asynchronous COM1 serial port.
The execution of the script requires Tera Term Software installed on the user’s computer. The Tera Term software can be downloaded from the following URL:
http://hp.vector.co.jp/authors/VA002416/teraterm.html
The Procedure for execution of the script is as follows:
- Download Tera Term from the above mentioned URL.
- Unzip and downloaded file and execute the Setup.exe file.
- Install the Software in a specified destination.
- Copy the below provided script in the Tera Term directory.
- The script has an extension of .TTL and can be opened in notepad.
- Open the file in notepad and change the variable ‘dirname’ in the script to reflect your Tera Term Directory.
- Make two Text Files in the directory specified by the variable ‘dirname’ by the following names:
ip.txt
commands.txt
- Make sure you have telnet access to all the devices you would like to configure.
- Open the ip.txt file and enter the IP addresses of all the devices for which the configuration needs to be fetched or pushed. Place only one IP address per line.
- Open the commands.txt file and enter the commands for configuration or commands for fetching configuration from the devices. Please note that the commands need to be compatible on all the devices entered in the ip.txt file. Please put in the commands in sequential order as you would configure the device in the normal circumstances. For eg:
terminal length 0
show running-config
config t
enable secret cisco
exit
terminal length 24
write memory
- Please place the commands that are required after authentication is done. The script expects a device prompt (which can be customized easily) by default after authentication. You may change it at any point of time.
- Execute the file ttpmacro.exe present in the Tera Term directory and select the macro '.ttl’ extension.
- Please enter the Username for logging into the devices and press OK. Please note the Username and Password prompt would appear only once. The same username and password would be used to login into all the devices.
- Please enter the password in the Password Prompt Dialog Box and press OK.
- For Enable Password Authentication Prompt, click yes if you have enable password authentication configured in atleast some of the devices or click no if you don’t have enable password configured in any of the devices.
- If yes, then provide the enable password to log into all the devices. The password is assumed to be common on all the devices.
- For the Logging Dialog Box. Click yes if you want to log the output or click no if you don’t want to log the output.
- If yes, enter the directory in which the logs have to be placed. For eg: If the directory is ‘C:logs’ then enter it in the following format:
c:logs
- Please note that the ‘’ sign is important after you enter the directory path and name.
- Sit back and relax, as the commands entered in the commands.txt file is executed in every device entered in ip.txt.
P.S.: While fetching configuration from any device like that of Cisco, please make sure to keep the terminal length to zero so that the device prompt appears immediately after the execution of the command.
Please give your feedbacks to make it better.
Below is the script for use with Tera Term. Just copy & paste the below code in a notepad and save it with a TTL extension.
;#######################################################
;Version 3.2 (Untested Beta Version)
;Created on 25/03/2007
;For Tera Term Macro Use Only
;Created originally for Cisco Switch & Routers.
;Customizable script, please feel free to edit it.(In fact you have to edit it)
;For usage, execute ttpmacro.exe and select this script
;Write all the ip addresses in sequential order in a file by the name of 'ip.txt'
;Write all the commands in sequential order in a file by the name of 'commands.txt'
;and place the text files in the directory as set by the 'setdir' keyword.
;Complaints and suggestions for improvement welcome.
;Please feel free to take it to the next level and share it with others.
;#######################################################
;######################################################
;Main Script
;######################################################
timeout = 5
dirname = 'E:Program FilesTTERMPRO313'
setdir dirname
fileopen addressfile 'ip.txt' 0
inputbox 'Username:' 'Username Prompt'
Username = inputstr
passwordbox 'Password:' 'Password Prompt'
Password = inputstr
yesnobox 'Is enable password authentication required?' 'Enable Password Question'
if result=0 then
goto jumper1
endif
passwordbox 'Enable Password:' 'Enable Password Prompt'
Enable = inputstr
:jumper1
yesnobox 'Would you like to log the output?' 'Logging'
Logger = result
if Logger = 0 then
goto looper1
endif
inputbox 'Directory path & name followed by ' 'Logging Directory'
loggerpath = inputstr
dirmaker = 'cmd /C md '
strconcat dirmaker loggerpath
exec dirmaker
:looper1
filereadln addressfile ip
connect ip
if result = 1 then
goto fclose1
endif
wait 'Username:' 'Password:' '>' 'login:'
if result = 0 then
call terminator
goto looper1
elseif result = 1 then
goto jumper4
elseif result = 2 then
goto jumper5
elseif result = 3 then
goto jumper6
elseif result = 4 then
goto jumper4
endif
:jumper4
sendln Username
wait 'Password:'
:jumper5
sendln Password
if Logger = 0 then
goto jumper2
endif
loggerfile = loggerpath
strconcat loggerfile ip
logopen loggerfile 0 0
loggerfile = '
:jumper2
wait '#' '>'
if result = 0 then
call terminator
elseif result = 1 then
call commander
call terminator
elseif result = 2 then
:jumper6
call enabler
call commander
call terminator
endif
goto looper1
:fclose1
fileclose addressfile
closett
end
;################################################
;Enabler is a sub-routine which provides enable password authentication.
;################################################
:enabler
setdir dirname
sendln 'enable'
wait 'Password:'
sendln Enable
return
;#####################################
;Commander is a sub-routine which executes the
;commands placed in 'commands.txt' file
;#####################################
:commander
setdir dirname
fileopen commandfile 'commands.txt' 0
:looper2
filereadln commandfile statement
if result goto fclose2
sendln statement
wait '#' '>'
if result = 2 then
goto fclose2
endif
goto looper2
:fclose2
fileclose commandfile
return
;###########################################
;Terminator is a sub-routine which provides terminal closure and
;passing the control to the main sub-routine for loop completion.
;###########################################
:terminator
beep
if Logger = 0 then
goto jumper3
endif
logclose
:jumper3
closett
return
;###########################################
The terminal emulation program Tara Term is an easy-to-use terminal emulator, similar in function to HyperTerminal or Procomm. But, Raveon finds it is easier to use, more reliable, and has better features. One of its new features is the ability to process a “Macro File”. It is a very handy program to communicate with a Raveon data radio modem, and is a good way to automate the configuing your radio modem.
Tera Term is an open-source terminal emulation program that is easy to use, and very powerful. Raveon recommends using it over Hyperterminal. Version 4.7 is currently available for download at logmett.com here: http://logmett.com/index.php?/download/download-tera-term-470-freeware.html Tera Term has a Macro FIle script processor that allows a person to create a script file of macro commands. The Script file can configure the radio modem, prompt the user for input, and validate the programming of the radio modem.
Tera Term Macro files have an extension .TTL. When in install Tera Term, the .TTL extension will be associated with Tera Term, so anytime you click on a .TTL file, the Tera Term maco processor should run it. If it does not, you can manually associate the “TLL” file as described below.
The macro File with the .TTL extension must be created before you can run it. Raveon may provide this for you, or you may create this yourself. Information about Tera Term’s Macro abilities is here:http://ttssh2.sourceforge.jp/manual/en/macro/ although you may have to search the Internet for more details. A good way to understand it, is to study a macro file provided by Raveon.
When you run a macro file, there will be at least two windows pop-up, and maybe three windows. The largest window is the Tera Term program itself. As the macro runs, there will be a small window titled MACRO – xxxxx where xxxxx is the name of the macro file that is running. You can pause or end the macro execution by clicking on a button on this window.
At various plces in the macro file script, the user may be promoted to enter a paramter, or answer yes/no to a question. A good practice at the end of the script is have the macro script close Tera Term so another script may be started.
How to associate “TTL” files with MACRO
Since Tera Term 4.59, you can associate “.TTL” files with MACRO with installer. To associate the file extension “.TTL” with MACRO, do the following steps.
- Execute the [View] Options command of Explorer.
- Select the “File Types” tab.
- Click the “New Type” button and specify items like the following.
- Click the “New” button and specify items like the following.
- Close all the dialog boxes by clicking “OK” buttons.
Macro Example
Below is a simple example macro script to program a Raveon M7 radio modem.
Following is a quick overview of the Tera Term Macro Language.
Identifiers and reserved words
1) Variable identifiers
The first character must be an alphabetic (A-Z, a-z) or an underscore character '_'. Subsequent characters can be alphabetic, underscore or numeric (0-9). Variable identifiers are not case sensitive. The maximum length is 32.
2) Label identifiers
Label identifiers consist of alphabetic, underscore or numeric characters, and are not case sensitive. The maximum length is 32.
3) Reserved words
The following words are reserved:
Line formats
There are four kinds of line formats for macro files. Any line can contain a comment which begins with a ';' character. Also, a user can use the C language style comment(/* - */).
Comments give no effect on the execution of MACRO.
One line can contain up to 500 characters. The part that exceeded 500 characters is ignored.
1) Empty lines
Lines which have no character or contain only space or tab characters or a comment. They give no effect on the execution of the macro.
2) Command lines
Lines containing a single command with parameters.
3) Assignment lines
Lines which contain an assignment statement.
4) Label lines
Lines which begin with a ':' character followed by a label identifier.
Communication commands
- bplusrecv
- bplussend
- callmenu (version 4.56 or later)
- changedir
- clearscreen
- closett
- connect
- cygconnect (version 4.57 or later)
- disconnect
- dispstr (version 4.67 or later)
- enablekeyb
- flushrecv
- gethostname (version 4.61 or later)
- gettitle
- kmtfinish
- kmtget
- kmtrecv
- kmtsend
- loadkeymap
- logclose
- logopen
- logpause
- logstart
- logwrite
- quickvanrecv
- quickvansend
- recvln
- restoresetup
- scprecv (version 4.57 or later)
- scpsend (version 4.57 or later)
- send
- sendbreak
- sendbroadcast (version 4.62 or later)
- sendfile
- sendkcode
- sendln
- sendlnbroadcast (version 4.62 or later)
- sendmulticast (version 4.62 or later)
- setbaud (version 4.58 or later)
- setdebug (version 4.64 or later)
- setdtr (version 4.59 or later)
- setecho
- setmulticastname (version 4.62 or later)
- setrts (version 4.59 or later)
- setsync
- settitle
- showtt
- testlink
- unlink
- wait
- wait4all (version 4.63 or later)
- waitevent
- waitln
- waitn (version 4.62 or later)
- waitrecv
- waitregex (version 4.21 or later)
- xmodemrecv
- xmodemsend
- ymodemrecv (version 4.66 or later)
- ymodemsend (version 4.66 or later)
- zmodemrecv
- zmodemsend
Tera Term Macro Sample
Control commands
- break (version 4.53 or later)
- call
- do, loop (version 4.56 or later)
- end
- execcmnd
- exit
- for, next
- goto
- if, then, elseif, else, endif
- include
- mpause (version 4.27 or later)
- pause
- return
- until, enduntil (version 4.56 or later)
- while, endwhile
String operation commands
- code2str
- expandenv (version 4.71 or later)
- int2str
- sprintf (version 4.52 or later)
- sprintf2 (version 4.62 or later)
- str2code
- str2int
- strcompare
- strconcat
- strcopy
- strinsert (version 4.67 or later)
- strjoin (version 4.67 or later)
- strlen
- strmatch (version 4.59 or later)
- strremove (version 4.67 or later)
- strreplace (version 4.67 or later)
- strscan
- strspecial (version 4.67 or later)
- strsplit (version 4.67 or later)
- strtrim (version 4.67 or later)
- tolower (version 4.53 or later)
- toupper (version 4.53 or later)
File operation commands
- basename (version 4.69 or later)
- dirname (version 4.69 or later)
- fileclose
- fileconcat
- filecopy
- filecreate
- filedelete
- filemarkptr
- fileopen
- filereadln
- fileread (version 4.48 or later)
- filerename
- filesearch
- fileseek
- fileseekback
- filestat (version 4.66 or later)
- filestrseek
- filestrseek2
- filetruncate (version 4.67 or later)
- filewrite
- filewriteln
- findfirst, findnext, findclose
- foldercreate (version 4.69 or later)
- folderdelete (version 4.69 or later)
- foldersearch (version 4.69 or later)
- getdir
- getfileattr (version 4.69 or later)
- makepath
- setdir
- setfileattr (version 4.69 or later)
Password commands
- delpassword
- getpassword
- passwordbox
Miscellaneous commands
Tera Term Macro Examples In Writing
- beep
- closesbox
- clipb2var (version 4.46 or later)
- crc32 (version 4.60 or later)
- crc32file (version 4.60 or later)
- exec
- filenamebox (version 4.54 or later)
- getdate
- getenv
- gettime
- getttdir (version 4.60 or later)
- getver (version 4.58 or later)
- ifdefined (version 4.46 or later)
- inputbox
- messagebox
- random (version 4.27 or later)
- rotateleft (version 4.54 or later)
- rotateright (version 4.54 or later)
- setdate
- setdlgpos
- setenv (version 4.54 or later)
- setexitcode
- settime
- show
- statusbox
- var2clipb (version 4.46 or later)
- yesnobox
Tera Term Macro Examples
PAUSE 1