use strict; use warnings; use Expect; $|++; my $exp = new Expect; $exp->raw_pty(1); $exp->log_file("/tmp/expect.out"); $exp->log_stdout(1); my @commands = ( "This is the first command", "Here is the second command", "error", "commit", "This is the last command", "exit", ); $exp->spawn("./expecttest_server.pl"); foreach my $command (@commands) { print "$command\n"; $exp->send("$command\n"); $exp->expect(1, '-re','\(\d+\)'); } $exp->soft_close();