#!/usr/bin/perl -w

use Expect;

my $exp = Expect->spawn("gettextize", @ARGV) or die "Cannot spawn gettextize: $!\n";
my $spawn_ok;
my $timeout=60;

$exp->expect($timeout,
	       [
		qr'Press Return to acknowledge the previous three paragraphs.',
		sub {
                  $spawn_ok = 1;
		  my $fh = shift;
		  $fh->send("\n");
                  exp_continue;
		}
	       ],
	       [
		eof =>
		sub {
                  if ($spawn_ok) {
		    die "ENTER provided by wrapper.\n";
                  } else {
		    die "ERROR: No ENTER provided.\n";
                  }
		}
	       ],
	       [
		timeout =>
		sub {
		  die "Seems to be long, stop there after 60 seconds.\n";
		}
	       ],
	      );


