Auto exit Telnet command back to prompt without human intervention ^] quit close exit code 1

前端 未结 5 913
灰色年华
灰色年华 2020-12-31 20:12

I\'m running telnet command on a host for a given port (which is open), it returns 0 (success).

For trying telnet manually, I type the following comman

5条回答
  •  猫巷女王i
    2020-12-31 20:42

    ╭─ ~
    ╰» echo "^]close^M" | telnet localhost 22; echo $?
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    
    telnet> close
    Connection closed.
    0
    

    To enter the ^] and ^M characters, press ctrl+v ctrt+] and ctrl+v ctrl+m respectively.

提交回复
热议问题