in reply to Re^3: Perl Expect
in thread Perl Expect

nicetelnet is just a wrapper on top of telnet. reposing the code.

#!/usr/bin/perl use strict; use Expect; my $session = new Expect; $session->spawn("telnet $my_ip"); $session->expect(90, -re, "login:"); print $session "regress\r"; $session->expect(90, -re, "Password:"); print $session "MaRtInI\r"; $session->expect(90, -re, ".*"); print $session "pwd\r"; $session->expect(90, -re, ".*"); $session->close()

Replies are listed 'Best First'.
Re^5: Perl Expect
by salva (Canon) on Jan 18, 2018 at 07:39 UTC
    Expect provides several methods for retrieving the matching data and also the last error. Have you experimented with them? Expect should be able to detect the slave process has terminated and report it accordingly.

    You could also try Net::Telnet. That module doesn't depend on an intermediate program and shouldn't have any problem detecting a remote closed connection (in case Expect has any).