[ale] Expect?

Chris Fowler cfowler at outpostsentinel.com
Wed Feb 9 18:19:18 EST 2011


On Wed, 2011-02-09 at 12:59 -0700, Robert L. Harris wrote:

> The problem is the streambaby process will throw the java.io error but
> not die.  I just want to kill it and respawn it, wait for it to die
> again.  if I could get the kill command to work I'd be set.

#!/usr/bin/perl

use Expect;
use strict;

sub worker {
	my $exp = Expect->spawn("/usr/local/streambaby/streambaby");
	$exp->expect(undef, "java.io.IOException");
	print "     **** Killing *****\n";
	my $pid = `pgrep -f 'java.*streambaby.jar'`;
	chomp $pid;
	kill 9, $pid;
        return;
}

while(1) {
  worker();
}


Multiple ways to solve the problem.



More information about the Ale mailing list