2 |
## $Id$ |
## $Id$ |
3 |
## --------------------------------------------------------------------------- |
## --------------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.20 2004/06/21 14:13:21 jonen |
6 |
|
## added helper function |
7 |
|
## |
8 |
|
## Revision 1.19 2004/05/11 19:45:30 joko |
9 |
|
## now exporting RUNNING_IN_HELL |
10 |
|
## |
11 |
|
## Revision 1.18 2003/12/05 04:58:04 joko |
12 |
|
## + minor update: doesn't require IPC::Session anymore |
13 |
|
## |
14 |
|
## Revision 1.17 2003/07/02 11:17:32 jonen |
15 |
|
## minor changes |
16 |
|
## |
17 |
|
## Revision 1.16 2003/06/25 22:49:56 joko |
18 |
|
## RUNNING_IN_HELL mode for detach option |
19 |
|
## |
20 |
## Revision 1.15 2003/06/24 20:21:12 jonen |
## Revision 1.15 2003/06/24 20:21:12 jonen |
21 |
## + changed linux part of run_cmd to use Proc::Background instead of IPC::... |
## + changed linux part of run_cmd to use Proc::Background instead of IPC::... |
22 |
## |
## |
83 |
get_chomped |
get_chomped |
84 |
bool2status |
bool2status |
85 |
make_guid |
make_guid |
86 |
|
RUNNING_IN_HELL |
87 |
|
RUNNING_IN_HEAVEN |
88 |
); |
); |
89 |
|
|
90 |
|
|
95 |
use Carp; |
use Carp; |
96 |
|
|
97 |
# NEW - 2003-06-23 for Linux (what about *BSD?) |
# NEW - 2003-06-23 for Linux (what about *BSD?) |
98 |
use IPC::Session; |
#use IPC::Session; |
99 |
|
|
100 |
use File::Spec; |
use File::Spec; |
101 |
use Proc::Background; |
use Proc::Background; |
116 |
} |
} |
117 |
|
|
118 |
sub RUNNING_IN_HELL () { $^O eq 'MSWin32' } |
sub RUNNING_IN_HELL () { $^O eq 'MSWin32' } |
119 |
|
sub RUNNING_IN_HEAVEN () { $^O =~ m/bsd/ } |
120 |
|
|
121 |
|
|
122 |
sub get_executable { |
sub get_executable { |
230 |
$cmd = "$application$cmd" if $application; |
$cmd = "$application$cmd" if $application; |
231 |
#} |
#} |
232 |
|
|
233 |
|
my @cmd = split(' ', $cmd); |
234 |
|
|
235 |
# V3 - using IPC (optional) |
# V3 - using IPC (optional) |
236 |
if ($options->{async}) { |
if ($options->{async}) { |
237 |
|
|
238 |
#run \@cmd, \$in, \$out, \$err, timeout( 10 ) or die "cat: $?"; |
#run \@cmd, \$in, \$out, \$err, timeout( 10 ) or die "cat: $?"; |
239 |
my @cmd = split(' ', $cmd); |
|
240 |
|
print STDOUT "run_cmd[async]: Proc::Background: $cmd", "\n"; |
241 |
|
|
242 |
# V3.1 - using IPC::Run |
# V3.1 - using IPC::Run |
243 |
# |
# |
246 |
if (RUNNING_IN_HELL()) { |
if (RUNNING_IN_HELL()) { |
247 |
|
|
248 |
#my $in; my $out; my $err; |
#my $in; my $out; my $err; |
|
print STDOUT "run_cmd: IPC::Run: $cmd", "\n"; |
|
249 |
|
|
250 |
#print STDOUT "findpath: ", findpath('rap.pl'), "\n"; |
#print STDOUT "findpath: ", findpath('rap.pl'), "\n"; |
251 |
|
|
337 |
|
|
338 |
|
|
339 |
} elsif ($options->{detach}) { |
} elsif ($options->{detach}) { |
340 |
print STDERR "run_cmd: system('$cmd' &).", "\n"; |
|
341 |
system($cmd . ' &'); |
if (RUNNING_IN_HELL()) { |
342 |
|
print STDOUT "run_cmd[detach]: Proc::Background: $cmd", "\n"; |
343 |
|
my $proc1 = Proc::Background->new(@cmd); |
344 |
|
print "pid: ", $proc1->pid(), "\n"; |
345 |
|
} else { |
346 |
|
print STDOUT "run_cmd[detach]: system('$cmd' &).", "\n"; |
347 |
|
system($cmd . ' &'); |
348 |
|
} |
349 |
|
|
350 |
} else { |
} else { |
351 |
print STDOUT "run_cmd: system('$cmd').", "\n"; |
print STDOUT "run_cmd: system('$cmd').", "\n"; |
352 |
|
#print $ENV{PERL5LIB}, "\n"; |
353 |
system($cmd); |
system($cmd); |
354 |
} |
} |
355 |
|
|