Expect

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

1.03
    Reworked expect() to make the code more fluid. Removed ~50 lines of
      cruft. Added soft_close() and hard_close() (see Expect.pod for details).

1.02
    Killed the $Expect::Use_Regexps stuff. Changed expect to look for '-re'
      strings indicating the subsequent pattern is to be matched as a regular
      expression.

1.01 1997-12-15
    Dropped process still alive during expect. Sometimes the process dies
      before the handle finishes getting read. Fixed a typo that caused a response
      of 'child process died' if a successfull pattern had a null value.
    Added the ability to do expect() literals instead of regular
      expressions. see $process->use_regexps and the package global 
      $Expect::Use_Regexps.
    Fixed internals to work with the documented fashion for using file
      ojects. everything is internally represented as ${*$process}{exp_variable} 
      instead of ${*$process}{variable}. Pids should be checked with 
      $process->pid() now, since $process->{Pid} no longer exists.
    exp_kill() is obsolete. Use kill($signal,$process->pid()).

lib/Expect.pm  view on Meta::CPAN

	print STDERR "Attempting interconnection\r\n" if $Expect::Debug;

	# Wait until the process dies or we get EOF
	# In the case of !${*$handle}{exp_Pid} it means
	# the handle was exp_inited instead of spawned.
	CONNECT_LOOP:

	# Go until we have a reason to stop
	while (1) {

		# test each handle to see if it's still alive.
		foreach my $read_handle (@handles) {
			waitpid( ${*$read_handle}{exp_Pid}, WNOHANG )
				if ( exists( ${*$read_handle}{exp_Pid} )
				and ${*$read_handle}{exp_Pid} );
			if (    exists( ${*$read_handle}{exp_Pid} )
				and ( ${*$read_handle}{exp_Pid} )
				and ( !kill( 0, ${*$read_handle}{exp_Pid} ) ) )
			{
				print STDERR
					"Got EOF (${*$read_handle}{exp_Pty_Handle} died) reading ${*$read_handle}{exp_Pty_Handle}\r\n"

lib/Expect.pm  view on Meta::CPAN


Returns a string representation of the attached pty, for example:
`spawn id(5)' (pty has fileno 5), `handle id(7)' (pty was initialized
from fileno 7) or `STDIN'. Useful for debugging.


=item $object->restart_timeout_upon_receive(0 | 1)

If this is set to 1, the expect timeout is retriggered whenever something
is received from the spawned command.  This allows to perform some
aliveness testing and still expect for patterns.

    $exp->restart_timeout_upon_receive(1);
    $exp->expect($timeout,
                 [ timeout => \&report_timeout ],
                 [ qr/pattern/ => \&handle_pattern],
                );

Now the timeout isn't triggered if the command produces any kind of output,
i.e. is still alive, but you can act upon patterns in the output.


=item $object->notransfer(1 | 0)

Do not truncate the content of the accumulator after a match.
Normally, the accumulator is set to the remains that come after the
matched string.  Note that this setting is per object and not per
pattern, so if you want to have normal acting patterns that truncate
the accumulator, you have to add a



( run in 0.455 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )