Script to connect, then set date and time


Author Message
James_From_Canb

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 265
Posted: 02:08am 19 Jun 2011      

I downloaded the latest version (V4.69) of TeraTerm from Sourceforge. It's powerful.

The script below sets the title of the terminal window, connects to the MaxiMite and sets the date and time. The macro language can also process screen output from the Maximite which looks interesting.

Try this....

Cut and paste the script below to a file called start-mm.ttl.
Change the number of the com port to the one you use.
Save the file to somewhere easily accessible.

Windows 7 is a pain in the proverbial for this sort of thing. I cannot save the macro file in the same directory as the program. It's good security, but difficult for older programs like this. I suggest saving it on a thumb drive, or any drive except C:. I tried my E: drive and I couldn't save it, but I could on my M: drive. Go figure.

Create a new shortcut, or change the Target properties of the Tera Term icon to "C:\Program Files (x86)\teraterm\ttpmacro.exe" "m:\start-mm.ttl"
Note that it's no longer starting Tera Term, it's starting the Tera Term macro program, which starts Tera Term and executes the commands. You'll have to change the drive letter / location of the macro from m:\ to whereever you saved the script.

Now, when you click on the icon, it opens Tera Term and sets the time and date on the Maximite. Neat.

Here's the script:

;; Tera Term Macro
;; ============================================================ ================
;; file start-mm.ttl
;;
;; desc A startup macro for Tera Term, customised for the Maximite
;; ============================================================ ================
;; HISTORY
;;
;; 2011-06-19 James Deakins
;; Original Version
;;
;; BASED ON CODE FROM
;; http://processors.wiki.ti.com/index.php/Teraterm_Scripts
;; ============================================================ ================


;; ============================================================ ================
;; DEFINITIONS
;; ============================================================ ================

;;
;; COM port - >>> you will have to replace the 3 with your com port number <<<
;;

myComPort = "3"

;;
;; Title of the Tera Term Window
;;
StrWindowTitle = 'MaxiMite Terminal'


;;
;; Current Date
;;
getdate CurDate "%d/%m/%Y"


;;
;; Current Time
;;
gettime CurTime "%H:%M:%S"



;; ============================================================ ================
;; CONNECT TO MAXIMITE, NAME TERMINAL WINDOW and UPDATE MAXIMITE DATE and TIME
;; ============================================================ ================

;;
;; Connect
;; -------
myConnectString = "/C="
strconcat myConnectString myComPort
connect myConnectString

;;
;; Set window title
;; ----------------
settitle StrWindowTitle

;;
;; Set the Date
;;
Sendln 'DATE$="'CurDate'"'

;;
;; Set the Time
;; ------------
Sendln 'TIME$="'CurTime'"'M:\