How can I screen-scrape output from telnet in Perl?

后端 未结 6 356
死守一世寂寞
死守一世寂寞 2021-01-18 00:13

I can setup a telnet connection in Perl no problems, and have just discovered Curses, and am wondering if I can use the two together to scrape the output from the telnet ses

6条回答
  •  离开以前
    2021-01-18 00:24

    You probably want something like Expect

    use strict;
    use warnings;
    
    use Expect;
    
    my $exp = Expect->spawn("telnet google.com 80");
    
    $exp->expect(15, #timeout
            [
                    qr/^Escape character.*$/,
                    sub {
                            $exp->send("GET / HTTP/1.0\n\n");
                            exp_continue;
                    }
            ]
    );
    

提交回复
热议问题