Creating a script for a Telnet session?

前端 未结 11 1943
孤街浪徒
孤街浪徒 2020-11-30 02:16

Does anyone know of an easy way to create a script that can connect to a telnet server, do some usual telnet stuff, and then log off? I am dealing with users who are not fa

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 02:52

    Bash shell supports this out-of-box, e.g.

    exec {stream}<>/dev/tcp/example.com/80
    printf "GET / HTTP/1.1\nHost: example.com\nConnection: close\n\n" >&${stream}
    cat <&${stream}
    

    To filter and only show some lines, run: grep Example <&${stream}.

提交回复
热议问题