Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

telnet

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     
like image 231
Bernie Avatar asked Jul 27 '12 04:07

Bernie


People also ask

How to close telnet session in shell script?

To exit the Telnet session, type Ctrl + ] on your keyboard. This changes the command prompt to show as telnet>. Back in the terminal, type in the word 'close' to close the session.

Can t close telnet?

Answer: To end your current telnet session you must reach the telnet prompt and type quit. Here are the steps for doing so: Open the telnet prompt by holding down the 'Ctrl' key and push the ']' key.


1 Answers

On Linux it's actually:

CTRL + ] then ENTER

Finally type in the quit command.

^]  telnet> quit Connection closed. [fred@localhost ~]$ 
like image 81
Kajackdfw Avatar answered Sep 22 '22 10:09

Kajackdfw