Can't close a scpi(telnet) session with echo "^]" when I use it in a script

Viewed 73415

The use of echo-e "\ 029" does not work either. But if use strg + alt gr + ] directly in a terminal session -> it works.

I have to ask my question more concretely:
I connect an RF generator (AGILENT) via Telnet/SCPI.
If I do this manual on terminal and press at the end of the session CTRL + ALT GR +] for '^]' then close the scpi session properly and I can type quit to close the telnet session properly.
There is no error message on the display of the RF generator. So it should be.

If I do this via script the SCPI session seems not to recognize the break signal condition '^]' and will be forced to close after the end of the script (telnet and scpi). -> Message: "Disconnected by foreign host". Unfortunately, I get error messages on the display of the RF generator -> "invalid header", etc.

After successful connection appears: Connected to 192,168.10.66 Escape Character is ‘^]’ -> This is the point at issue. Manual entry in the terminal works correctly, script does not work.

My script looks something like this:

function  getIDNMessage()  
{
    (      
        echo open $1 $2  
        sleep 1  
        echo "*IDN?"  
        sleep 1  
        echo –e "\029"         # or echo “^]” does not work well  
        sleep 1  
        echo "quit\r"  
        sleep 1  
    ) | telnet > scpi_telnet.log 2>&1
}

getIDNMessage 192.168.10.66 7777    
9 Answers

To Close Session Use below command

  1. Ctrl + ]
  2. telnet> quit

it works perfect in REHL and CentOS.

On my danish keyboard it was not Ctrl + å - but instead the key to the right side of å (which has a hat, a tilde and a umlaut)

On MacOS with Turkish keyboard try:
Ctrl + Option + ü

Then,
> quit

Ctrl + ] This will show as ^] and then

telnet> q q is for quit

When opening a connection you can specify the escape character. e.g.

[root@localhost ~]# telnet -e % localhost
Telnet escape character is '%'.
Trying 127.0.0.1...
Connected to localhost.
Escape character is '%'.

>%

telnet> quit
Connection closed.
[root@localhost ~]#

In here, I just used the % symbol to close the session, for that I had to tell telnet to use it as an escape character. I find this useful since the character ^] could be different on different keyboard layouts.

Related