Linux – Can’t close a scpi(telnet) session with echo “^]” when I use it in a script

linuxtelnet

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    

Best Answer

On Linux it's actually:

CTRL + ] then ENTER

Finally type in the quit command.

^]

telnet> quit
Connection closed.
[fred@localhost ~]$
Related Topic