2 |
## $Id$ |
## $Id$ |
3 |
## ---------------------------------------------------------------------- |
## ---------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.5 2003/03/27 15:03:03 joko |
6 |
|
## enhanced 'sub run_executable' |
7 |
|
## |
8 |
|
## Revision 1.4 2003/02/22 16:51:21 joko |
9 |
|
## + enhanced run_executable |
10 |
|
## modified logging output |
11 |
|
## |
12 |
## Revision 1.3 2003/02/21 01:46:17 joko |
## Revision 1.3 2003/02/21 01:46:17 joko |
13 |
## renamed core function |
## renamed core function |
14 |
## |
## |
48 |
my $self = shift; |
my $self = shift; |
49 |
my $targetname = shift; |
my $targetname = shift; |
50 |
|
|
51 |
$self->log("Performing Target '$targetname'.", 'notice'); |
my $header = ("- " x 12) . " " . $targetname . " " . ("- " x 6); |
52 |
|
|
53 |
|
#$self->log("- " x 35, 'notice'); |
54 |
|
#$self->log("Performing Target '$targetname'.", 'notice'); |
55 |
|
|
56 |
|
$self->log($header, 'notice'); |
57 |
|
|
58 |
#exit; |
#exit; |
59 |
|
|
114 |
my $command = shift; |
my $command = shift; |
115 |
|
|
116 |
if (!$command) { |
if (!$command) { |
117 |
$self->log("Command was empty!", 'warning'); |
$self->log("Command was empty!", 'debug'); |
118 |
return; |
return; |
119 |
} |
} |
120 |
|
|
299 |
my $program = $opts->{executable}; |
my $program = $opts->{executable}; |
300 |
delete $opts->{executable}; |
delete $opts->{executable}; |
301 |
|
|
302 |
|
# determine execution method |
303 |
|
my $method = 'run_cmd'; |
304 |
|
my $wrapper_program = ''; |
305 |
|
|
306 |
|
# check if program is a namespace-string (contains '::') - use 'do' in this case! |
307 |
|
if ($program =~ /::/) { |
308 |
|
#if ($program =~ s/::/\\/g) { |
309 |
|
#$program = '.\\' . $program; |
310 |
|
#$method = 'require'; |
311 |
|
#do "$program"; |
312 |
|
#return; |
313 |
|
#$method = 'rap.'; |
314 |
|
|
315 |
|
$wrapper_program = 'rap.pl'; |
316 |
|
|
317 |
|
} |
318 |
|
|
319 |
|
# prepare arguments |
320 |
my @buf; |
my @buf; |
321 |
foreach (keys %$opts) { |
foreach (keys %$opts) { |
322 |
my $value = $opts->{$_}; |
my $value = $opts->{$_}; |
323 |
|
if (m/^_/) { |
324 |
|
if ($_ eq '_switches') { |
325 |
|
my @switches = split(/,\s|,/, $value); |
326 |
|
foreach my $switch (@switches) { |
327 |
|
push @buf, '--' . $switch; |
328 |
|
} |
329 |
|
} |
330 |
|
next; |
331 |
|
} |
332 |
|
|
333 |
if ($value =~ /\s/) { |
if ($value =~ /\s/) { |
334 |
$value = "\"$value\""; |
$value = "\"$value\""; |
335 |
} |
} |
336 |
push @buf, "--$_=$value"; |
push @buf, "--$_=$value"; |
337 |
} |
} |
338 |
|
|
339 |
my $cmd = $program . ' ' . join(' ', @buf); |
# build {program} & {arguments} |
340 |
|
my $cmd = join(' ', $wrapper_program, $program) . ' ' . join(' ', @buf); |
341 |
|
|
342 |
# trace |
# trace |
343 |
#print "command: $cmd", "\n"; |
#print "command: $cmd", "\n"; |
350 |
$ENV{PERL5LIB} = $INC[0]; |
$ENV{PERL5LIB} = $INC[0]; |
351 |
|
|
352 |
#print Dumper(%ENV); |
#print Dumper(%ENV); |
353 |
run_cmd($cmd); |
|
354 |
|
print "command: '$cmd'", "\n"; |
355 |
|
|
356 |
|
# V1 - basic |
357 |
|
#run_cmd($cmd); |
358 |
|
|
359 |
|
# V1.b - enhanced: variable local method |
360 |
|
my $evalstr = "$method('$cmd');"; |
361 |
|
eval($evalstr); |
362 |
|
#my $res = do "$cmd"; |
363 |
|
#print $res, "\n" if $res; |
364 |
|
|
365 |
|
#$self->log("run_executable: $evalstr", 'info'); |
366 |
|
$self->raiseException("run_executable: $evalstr\n$@") if $@; |
367 |
|
|
368 |
# V2: via IPC::Run |
# V2: via IPC::Run |
369 |
# .... (TODO) |
# .... (TODO) |
370 |
|
|