GTM::Run - run interactive processes
use GTM::Run;
my $hdl = new GTM::Run ("mumps -direct");
$hdl->expect(
qr/GTM\>/,
qr/^%.*/m,
sub {
die $_[1] if $_[2];
shift->write ("D ^\%GO\n");
}
);
This module is a helper-module for running interactive processes in a "expect"-like way.
Creates a GTM::Run object. The $command is either a single string, which is then passed to a shell, or an arrayref, which is passed to the "execvp" function. If command is not a fully qualified command (ie: starts not with /) $ENV{gtm_dist} will be prepended.
Closes the command. This runs waitpid so be sure that your command will terminate. For mumps this means that "Halt\n" must be written before.
writes $data to the process
writes regular expression debug-info to STDERR if enabled. Here an example:
$self->expect(
qr/^No globals selected/m,
qr/^Header Label:/m,
sub {
...
},
);
This writes:
RE: (?m-xis:^No globals selected) == 0 RE: (?m-xis:^Header Label:) == 1 RE: match index == 1
if debugging is enabled.
Waits for input that matches one of the given regular expressions. &cb will be invoked with three arguments: $class, $data, $reidx. $reidx is the index of the regular expression that matched.
A callback may die - close will be invoked and the die gets propagated. Subsequent callbacks within the same expect-call will be skipped.
Waits until the output buffer is empty.
GTM
Stefan Traby <stefan@hello-penguin.com> http://oesiman.de/gt.m/