Tera Term Macro Examples

Posted on by
Tera Term Macro Examples Rating: 5,0/10 2792 votes

PC based Tera-term macro or Python script example to send a “GET” using DNS lookup to a HTTP Server.

  1. Down load Tera Term
  2. Connect the eS-Wifi module to the PC
  3. Setup the comm port and Tera Term terminal with Transmit and Receive with CR+LF
  4. Edit the Macro with your router with ssid, password, security type
  5. Under the Tera-Term “Control” drop down menu select “Macro” and point to unzip HTTP macro below.
Tera Term Macro Examples

Recommended tools:

  1. Teraterm
  2. HTTP Get Macro (zip) or see code below
  3. eS-WiFi drivers ( easily installed using ourPC demo application (ZIP)
Term

Optional tools:

If you prefer Python – Python example

Tera Term (alternatively TeraTerm) is an open-source, free, software implemented, terminal emulator (communications) program. Databases obsolete but update fails at 78% start. It emulates different types of computer terminals, from DEC VT100 to DEC VT382. It supports telnet, SSH 1 & 2 and serial port connections. It also has a built-in macro scripting language (supporting Oniguruma regular expressions) and a few other useful plugins.

  • MACRO (TTPMACRO.EXE) is an interpreter of the macro language 'Tera Term Language (TTL)', which controls Tera Term and provides various functions like auto dialing, auto login and so on. Usage How to run a macro file.
  • I know Tera Term has a site that lists example macros as well as a command list but I guess what I need is someone with experience scripting in Tera Term. Tera Term uses a sort of Basic language called Tera Term Language (TTL) but I found it hard from the site to actually identify which commands I needed to use.

—————————————————————————-

Teraterm Macro – Setup, Terminal, New-Line should be set to CR+LF for both Receive & Transmit

;Fill in your ssid and password
SSID=””
PSWD=””

sendln ‘C1=’SSID
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

sendln ‘C2=’PSWD
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

sendln ‘C3=4’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

sendln ‘C0’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

;Default Remote port, [P4]
port = ’80’

;Protocol
proto = ‘0’

;Packet
;get//http://urlecho.appspot.com/echo?status=200&Content-Type=text%2Fhtml&body=Hello%20world
Pkt0 = ‘GET /echo?status=200&Content-Type=text%2Fhtml&body=Hello%20world HTTP/1.1’#$D#$A
Pkt1 = ‘Host: urlecho.appspot.com’#$D#$A’Connection: close’#$D#$A#$D#$A
;All HTTP request end in 1 blank line
dispstr Pkt0

sendln ‘I?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

sendln ‘R1=1460
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘R2=10000’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

sendln ‘R?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

Tera Term Macro Examples

sendln ‘S2=100’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

sendln ‘S?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

;Protocol settings
sendln ‘P?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Setup
sendln ‘P1=’proto
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

sendln ‘D0=urlecho.appspot.com’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

Tera Term Macro Examples

sendln ‘P4=’ port
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

sendln ‘P?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Connect
sendln ‘P6=1’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

;Send
send ‘S3=124’#$D Pkt0 Pkt1
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

;Receive
sendln ‘R0’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

;Disconnect
sendln ‘P6=0’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Jump to end
goto cend

;Command Error
:cerror
dispstr #13#10#10′[SCRIPT ] ***** Command Failed *****’#13#10#10′> ‘

;Exit
:cend
sendln ‘P6=0’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror

Examples

Teraterm Macro Examples Serial Port

sendln ‘CD’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror