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
On Linux it's actually:
CTRL + ] then ENTER
Finally type in the quit
command.
^]
telnet> quit
Connection closed.
[fred@localhost ~]$
To quit telnet on redhat:
type "CTRL+5"
and then type "quit"
To Close Session Use below command
- Ctrl + ]
- telnet> quit
it works perfect in REHL and CentOS.
The ^]
means ctrl + right
bracket. As strange as that is, it works. You'll be taken to the telnet prompt, where you can type quit.
On international keyboards the ]
character is often not a single key, and needs to be replaced with some other key. The correct key is typically the key to the right of P or the next key after that.
Here's a list based on comments below:
Finnish, Swedish, Norwegian, Danish: ctrl + å
French: ctrl + 6
German: ctrl + ü
Swiss: ctrl + ¨
Hungarian: ctrl + 5
Portuguese: ctrl + ´
Dutch, Belgian: ctrl + $
Canadian French: ctrl + ç
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)
Ctrl + ]
This will show as ^] and then
telnet> q
q is for quit
It must be so. Because ^]
printed in the terminal on the server means for the client side nothing. The client must catch this symbol before it will be transmitted to server and of course you can't just write it to terminal in te program running on the server.
So you need to interrupt session in other way. There are many methods.
- If you are inside the running program, you can simple terminate it (
exit
in shell or sys.exit()
in python or exit()
in many other languages).
- If you can't control program flow you can close terminal by killing the process that is owner of the terminal. You need to find the process and then use
kill ...
(PID of the process instead of ...
).
- If you want to close the client from client side, you need to do the same (
kill ...
) but on the client side.