可以使用MozRepl从telnet退出吗? [英] can we exit without error from telnet with MozRepl?

查看:195
本文介绍了可以使用MozRepl从telnet退出吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于此答案,我试图找出一种退出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 = 'http://v4.ident.me/'"; sleep 2; echo -e '\035'; sleep 2) | telnet localhost 4242 > /dev/null
$ echo $?
$ 0

这篇关于可以使用MozRepl从telnet退出吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆