Teratem - Invalid host

4.5k Views Asked by At

I feel quite useless with Teraterm.

I tried to create a simple macro macro.ttl that sends some stupid commands:

connect '/C=3'
sendln '?' 
sendln '|3'

in order to: connect '/C=3'- connect to Port 3 (althought it´s already in the config), sendln '?' - display help, sendln '|3' - enter this menu, etc.

This works when I open Teraterm and go to Macros and open the file but my problem now is how to handle this from the cmd window. I tried this:

start ttermpro.exe TTPMACRO "Teraterm_macros\macro.ttl"

basically: start Teraterm, open the macro and path and file name of the macro file. But it reports error:

Invalid host

Any hints, please? Thnx

2

There are 2 best solutions below

0
On

I thought about writing all the steps I followed just in case that someone like me (kind of d umb) was struggling with the same:

1 - Relate the .ttl with the Teraterm macro application:

1a - I went to my macro, click R-mouse, "Open with...", "Choose another app", "More apps", "Look for another app in this PC" and checked box "Always use this app to open .ttl files".

1b - I could not find the app first, then I found it in c:>Program Files (x86)> teraterm and selected the executable "ttpmacro.exe".

2 - Modify the macro to start the communication because Teraterm has to be closed for this to work, so when the macro starts Teraterm you need to specify the port:

2a - I added in my Teraterm macro: connect '/C=3' (in my case I connect Teraterm with COM port 3)

2b - Whole macro: it looks like this:

connect '/C=3' 
sendln '?' 
sendln '|3' 
sendln 'c' 
sendln '3'

This connects through com port 3 and then enters one menu and sends c and then 3. So now if I double click on the macro it executes the macro alone.

3 - Script to run the macro: Also I decided to create a batch file to run it from CAPL, and I did this:

3a - first close Teraterm if it´s already opened because the teraterm exe and the macro exe can´t connect at the same time:

tasklist /fi "IMAGENAME eq ttermpro.exe" | find /i "ttermpro.exe" > nul if not errorlevel 1 (taskkill /im ttermpro.exe) else (echo ttermpro already closed)

ttermpro.exe is the application name that runs when starting Teraterm normally.

3b - Start the macro:

"C:\workset\Teraterm_macros\mytmacro.ttl"

So it looks like this:

@echo off
echo.
echo .................................
echo .................................
echo .....  My teraterm macro .....
echo .................................
echo .................................
echo.

echo If Teraterm is launched it will be closed now. 

TIMEOUT /T 5 /NOBREAK 
REM this was to give the user 5seconds to cancel.

tasklist /fi "IMAGENAME eq ttermpro.exe" | find /i "ttermpro.exe" > nul
if not errorlevel 1 (taskkill /im ttermpro.exe) else (echo ttermpro already closed)
REM this is to close Teraterm if it´s opened already.

echo The calibration macro will be launched now. 
"C:\Teraterm_macros\mytmacro.ttl"
REM This is to start my macro. As I alread linked .ttl with the macro app it´ll open.


IF ERRORLEVEL 1 GOTO ERROR
GOTO END

:ERROR
echo my teraterm macro failed.
GOTO END

:END
::exit

4 - I call it from CAPL because what I want is to include this macro is one test: I add this line:

TestWaitForSyscall("C:\Teraterm_macros","\"scriptwithmytmacro.bat",0,20000);

this in CAPL opens the batch file. It could open directly the macro but I wanted to have a bat script so that I can add stuff like closing teraterm if it´s already open among other things.

1
On

The command, start ttermpro.exe TTPMACRO "Teraterm_macros\macro.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:

start ttermpro.exe /M="Teraterm_macros\macro.ttl"

where the /M option is defined as:

/M= Start Tera Term with macro. If this value is not a full path, it is understood as a relative path from ttermpro.exe.