情景linux–在剧本中怎么样优雅地退出telnet

情景linux–在剧本中怎样优雅地淡出telnet

情景

telnet命令是TELNET协议的用户接口,它辅助二种情势:指令方式对话形式。尽管telnet支持广大指令,但大部分动静下,大家只是使用它翻看指标主机是还是不是打开了某端口(暗中同意是23)

其履行结果有三种:

  • 端口未打开

$ telnet 101.199.97.65 62715

Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused

这时,命令已退出。

  • 端口已打开

$ telnet 101.199.97.65 62715

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.

那儿下令未脱离。
依照提醒Escape character is '^]'.可见退出字符为’^]’(CTRL+])。此时输入任何字符不能够使其剥离,CT福特ExplorerL+C都万分。输入CT中华VL+]后会自动执行,进入命令方式:

^]

telnet>

那儿再运营quit才会真的脱离。

telnet> quit

Connection closed.

其间,Escape character可以自定义,使用参数-e什么优雅地退出telnet,Linux中怎样利用脚本退出telnet。:

$ telnet -e p 101.199.97.65 62715
Telnet escape character is 'p'.
Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is 'p'.
p
telnet> quit
Connection closed.

即使如此,退出telnet仍然艰难。那么,更进一步,假设出现在剧本中应当如何(优雅地)退出telnet呢?

情景

telnet命令是TELNET协议的用户接口,它帮衬三种形式:指令情势对话方式。尽管telnet补助广大指令,但大部分场馆下,大家只是使用它查阅指标主机是或不是打开了某端口(暗中认可是23)

其实践结果有二种:

  • 端口未打开

$ telnet 101.199.97.65 62715

Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused

此刻,命令已脱离。

  • 端口已打开

$ telnet 101.199.97.65 62715

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.

那时候命令未脱离。
依照提醒Escape character is '^]'.能够退出字符为’^]’(CTRL+])。此时输入任何字符无法使其退出,CT景逸SUVL+C都充足。输入CT冠道L+]后会自动执行,进入命令情势:

^]

telnet>

那时再运维quit才会真正脱离。

telnet> quit

Connection closed.

内部,Escape character能够自定义,使用参数-e

$ telnet -e p 101.199.97.65 62715
Telnet escape character is 'p'.
Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is 'p'.
p
telnet> quit
Connection closed.

即使如此,退出telnet还是坚苦。那么,更进一步,假若出以后本子中应该怎么(优雅地)退出telnet呢?

情景

telnet命令是TELNET协议的用户接口,它补助二种情势:命令方式对话格局澳门金沙国际 ,。尽管telnet协助广大指令,但当先一全场所下,大家只是使用它查看目的主机是或不是打开了某端口(默许是23)

其履行结果有三种:

  • 端口未打开

$ telnet 101.199.97.65 62715

Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused

那时,命令已脱离。

  • 端口已打开

$ telnet 101.199.97.65 62715

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.

那儿下令未脱离。
依据提醒Escape character is '^]'.可见退出字符为’^]’(CTRL+])。此时输入任何字符无法使其剥离,CTLX570L+C都相当。输入CTRAV4L+]后会自动执行,进入命令形式:

^]

telnet>

那儿再运转quit才会真的脱离。

telnet> quit

Connection closed.

中间,Escape character能够自定义,使用参数-e

$ telnet -e p 101.199.97.65 62715
Telnet escape character is 'p'.
Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is 'p'.
p
telnet> quit
Connection closed.

尽管如此,退出telnet仍然辛劳。那么,更进一步,固然出现在剧本中应该怎么着(优雅地)退出telnet呢?

情景

telnet命令是TELNET协议的用户接口,它帮衬两种情势:指令形式对话情势。纵然telnet帮助广大指令,但抢先四分之二场地下,大家只是使用它翻开指标主机是或不是打开了某端口(暗许是23)

其进行结果有二种:

  • 端口未打开

$ telnet 101.199.97.65 62715

Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused

此刻,命令已脱离。

  • 端口已打开

$ telnet 101.199.97.65 62715

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.

那时候命令未脱离。
传闻提醒Escape character is '^]'.能够退出字符为’^]’(CTRL+])。此时输入任何字符不能使其剥离,CTRAV4L+C都非常。输入CT揽胜L+]后会自动执行,进入命令方式:

^]

telnet>

那时候再运行quit才会真正脱离。

telnet> quit

Connection closed.

里面,Escape character能够自定义,使用参数-e

$ telnet -e p 101.199.97.65 62715
Telnet escape character is 'p'.
Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is 'p'.
p
telnet> quit
Connection closed.

固然如此,退出telnet照旧辛劳。那么,更进一步,假如现身在本子中应该如何(优雅地)退出telnet呢?

方案

实则能够这么:

  • 出口结果后立即退出

$ echo "" | telnet 101.199.97.65 62715

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
Connection closed by foreign host.

$ echo "" | telnet 101.199.97.65 62715

Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused
  • 出口结果后推移退出
    sleep 2使得telnet输出结果后,停留2秒后脱离命令情势。

$ sleep 2 | telnet 101.199.97.65 62715

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
Connection closed by foreign host.

接纳那种方法得以将行业内部输出和正规错误重定向到文件中,通过分析文件的剧情来判定端口打开状态。

方案

其实能够这么:

  • 输出结果后当即退出

    $ echo "" | telnet 101.199.97.65 62715
    

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
Connection closed by foreign host.

$ echo "" | telnet 101.199.97.65 62715

Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused
  • 输出结果后延迟退出
    sleep 2使得telnet输出结果后,停留2秒后退出命令格局。

    $ sleep 2 | telnet 101.199.97.65 62715
    

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
Connection closed by foreign host.

利用那种方法得以将行业内部输出和标准错误重定向到文件中,通过分析文件的剧情来判定端口打开状态。

正文永久更新链接地址:http://www.linuxidc.com/Linux/2017-06/145164.htm

澳门金沙国际 1

方案

实则能够这么:

  • 出口结果后立刻退出

$ echo "" | telnet 101.199.97.65 62715

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
Connection closed by foreign host.

$ echo "" | telnet 101.199.97.65 62715

Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused
  • 输出结果后延迟退出
    sleep 2使得telnet输出结果后,停留2秒后退出命令格局。

$ sleep 2 | telnet 101.199.97.65 62715

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
Connection closed by foreign host.

运用那种艺术得以将规范输出和标准错误重定向到文件中,通过分析文件的剧情来判定端口打开状态。

方案

实则可以如此:

  • 出口结果后立刻退出

    $ echo "" | telnet 101.199.97.65 62715
    

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
Connection closed by foreign host.

$ echo "" | telnet 101.199.97.65 62715

Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused
  • 出口结果后推移退出
    sleep 2使得telnet输出结果后,停留2秒后脱离命令形式。

    $ sleep 2 | telnet 101.199.97.65 62715
    

Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
Connection closed by foreign host.

选择那种方式能够将正式输出和正规错误重定向到文件中,通过分析文件的始末来判断端口打开状态。

相关文章