in reply to Using Map and RegEx for data extraction

Something similar we're using at present.

We have 12 processes running on a remote Windows server, each started by a batch file. I added a line to each batch file, right after the line that invokes the actual process, to set the window title to "Doornail path/batchfile"; this identifies a process that has aborted. The perl looks for Doornail in the tasklist, kills the aborted ("zombie") window, and uses the second part of the window title to restart it. The loop is to limit how long this runs; I don't quite trust it to run on its own yet.

use strict; use warnings; my $looper = 0; my $qtrs = shift || 4; while ($looper < (4*$qtrs)+1) { my $counter = 0; $looper += 1; my @zombies = grep { $_ =~ /Doornail/ } `tasklist /v`; foreach my $z (@zombies) { $counter += 1; my ($pid, $batch) = (split /\s+/,$z)[1,10]; my ($path,$cmd) = $batch =~ m:^(.+/)([^/]+)$:; `taskkill /pid $pid`; chdir "/applications/JEDI/$path"; $batch = "start $cmd"; system($batch) } printf "Loop %d, restarted %d processes\n",$looper,$counter; sleep 15*60; }

Updated for clarity

1 Peter 4:10