Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

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

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 "29"         # or echo “^]” does not work well  
        sleep 1  
        echo "quit
"  
        sleep 1  
    ) | telnet > scpi_telnet.log 2>&1
}

getIDNMessage 192.168.10.66 7777    
question from:https://stackoverflow.com/questions/11681683/cant-close-a-scpitelnet-session-with-echo-when-i-use-it-in-a-script

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

On Linux it's actually:

CTRL + ] then ENTER

Finally type in the quit command.

^]

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...