基于此答案,我试图找出一种退出telnet的方式,并返回0
based on this answer, I am trying to figure out a way to exit from telnet and it return 0
这些不工作:
(echo -e "repl.quit()";sleep 1) |telnet localhost 4242;echo $? (echo -e "\029";sleep 1;echo "q";sleep 1) |telnet localhost 4242;echo $? (echo -e "\c]";sleep 1;echo "q";sleep 1) |telnet localhost 4242;echo $? (echo -e "\e]";sleep 1;echo "q";sleep 1) |telnet localhost 4242;echo $? (echo -e "\E]";sleep 1;echo "q";sleep 1) |telnet localhost 4242;echo $?问题是:我无法区分成功的退出和失败的一个...
The problem is: I am UNABLE to differentiate from a successful exit and a failed one...
我认为可以链接。
I think this question can be linked.
推荐答案你需要发送 ^] 字符,这是一个不可打印的组分隔符,您的telnet客户端在执行通过管道提供的所有命令后终止您的连接。大多数版本的 echo 程序可以使用 -e 选项生成不可打印的字符。组分隔符为035(八进制)(您可以在* nix系统上看到整个ASCII表与 man 7 ascii )。所以,整个命令应该如下所示:
You need to send ^] character, that is an unprintable group separator character before your telnet client terminates your connection after executing all commands you gave it via pipe. Most versions of echo program can produce unprintable characters using -e option. Group separator is 035 in octal (you can see the entire ASCII table with man 7 ascii on *nix systems.). So, the entire command should look like this:
$ (echo "content.location.href = 'v4.ident.me/'"; sleep 2; echo -e '\035'; sleep 2) | telnet localhost 4242 > /dev/null $ echo $? $ 0更多推荐
可以使用MozRepl从telnet退出吗?
发布评论