use strict; use warnings; use Expect; $Expect::Exp_Internal = 1; my $my_login = "xxx"; my $my_password = "yyy"; my $timeout = "5"; #Spawn a Telnet Process to connect to a build machine. my $exp = Expect->spawn("telnet aaa.bb.ccc.ddd") or die "Cannot Spawn Telnet...exiting\n"; #Send user name a password. $exp->expect($timeout, [ qr/^login:\s+$/i, sub { my $self = shift; $self->send("$my_login\n"); exp_continue; } ], [ qr/^password:\s+$/i, sub { my $self = shift; $self->send("$my_password\n"); exp_continue; } ], # [ qr/.*/i, sub { my $self = shift; # $self->send("/sean/test.pl\n"); # i exp_continue; } ], [ qr/^COMPLETE.*$/i, sub { my $self = shift; $self->send("exit\n"); exit; } ], [ qr/.*/i, sub { my $self = shift; exp_continue; } ], );