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 |
## Revision 1.4 2003/02/22 16:51:21 joko |
9 |
## + enhanced run_executable |
## + enhanced run_executable |
10 |
## modified logging output |
## modified logging output |
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->{$_}; |
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 |
|
|