Question Razvan Prepelita · Sep 8, 2017

run a cache terminal script from cmd/ batch.

Hello everyone, I'm trying to run a cache terminal script from cmd/ batch.
I run it like this C:\MyCache\bin#cterm.exe C:\Users\Me\Desktop\cache_scrip.scr
The command opens a terminal, but nothing happens, no title present, no log file written, no output, it's just stucked.
Here is my script:

case match: off
title MyTitle
; wait for the terminal to initialize and ask for our identification
echo: on
wait for:Username
send: MeUser<CR>
wait for:Password
send: mepass<CR>
logfile: C:\Users\Me\Desktop\cache_script.log
pause:10
send: znspace "ME_NAMESPACE"<CR>
wait for:ME_NAMESPACE>
send: do ##class(Me.MeMethod).UpdateRecordForCustomerId(1)<CR>
pause:30
send: do ##class(Me.MeMethod).UpdateRecordForCustomerId(2)<CR>
pause:30
send: do ##class(Me.MeMethod).UpdateRecordForCustomerId(3)<CR>
pause:30
; finish the session
send: <CR>
closelog
; finished
terminate

Thank you for your help

Comments

Peter Steiwer · Sep 8, 2017

I believe this is because you need to add a connection string to tell the terminal which instance to connect to. Please see this documentation for information on how to connect to a local instance or a remote instance

0
Razvan Prepelita  Sep 11, 2017 to Peter Steiwer

Well, your answers helped.
I've run the script using:
C:\InterSystems\Cache\bin\cterm.exe /console=cn_iptcp:127.0.0.1[23] C:\Users\ME\Desktop\cache_script_for_rest_call.scr
But now I have the following error:
TCP connect() failed - exception satisfied select().
Reason: (10061, 0x274d)) No connection could be made because the target machine actively refused it

0
Sergi Vaque  Feb 14, 2022 to Razvan Prepelita

If you don't want to deal with Telnet_Service, you could launch the cache terminal as:

Cterm.exe /console=cn_ap:<instanceName> <yourScript.scr> <username> <password>

or 

Iristerm.exe /console=cn_ap:<instanceName> <yourScript.scr> <username> <password>

0
Robert Cemper  Sep 11, 2017 to Razvan Prepelita

So enable connection in Mgmt Portal

0
John Murray  Sep 11, 2017 to Robert Cemper

Specifically, since you are trying to connect to port 23 on your local Windows machine you will need the Telnet service enabled. It's called %Service_Telnet.

Assuming you end up satisfied with Robert's answer, please remember to be a good DC citizen by setting the big checkmark alongside the header of his answer. Only you as OP can do this.

0
Sergi Vaque  Feb 3, 2022 to John Murray

Do you know whether can be "%service_telnet" enabled from cmd?

0
Jon Willeke  Sep 11, 2017 to Razvan Prepelita

If you're connecting to the local system, you don't need to use Telnet. Use the cn_ap option described in the link that Peter posted.

0
Charles Lambrecht · Sep 8, 2017

Where is your info to specify host?   /console=cn_iptcp : hostname[port]

I take it that the # after bin is a typo and you should have a \ there?

0