line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YVDHOVE::System; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
28830
|
use 5.008000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
63
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
398
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( execCMD ) ] ); |
13
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} }); |
14
|
|
|
|
|
|
|
our @EXPORT = (); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub execCMD($$$) { |
21
|
1
|
|
|
1
|
1
|
10
|
my ($cmd, $captureoutput, $debug) = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
5
|
print qq{execCMD: $cmd\n} if($debug); |
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
|
|
6
|
if ($captureoutput) { |
26
|
1
|
|
|
1
|
|
951
|
use IO::CaptureOutput qw(capture capture_exec qxx); |
|
1
|
|
|
|
|
35101
|
|
|
1
|
|
|
|
|
400
|
|
27
|
1
|
|
|
|
|
8
|
my ($stdout, $stderr) = capture_exec("$cmd"); |
28
|
1
|
|
|
|
|
24334
|
my $rc = ($? >> 8); |
29
|
1
|
|
|
|
|
12
|
my $signal = ($? & 127); |
30
|
1
|
|
|
|
|
3
|
my $coredump = ($? & 128); |
31
|
1
|
50
|
33
|
|
|
36
|
my $rv = ($stderr eq '' && $signal == 0 && $coredump == 0) ? 1 : 0; |
32
|
1
|
50
|
|
|
|
12
|
if($debug) { |
33
|
0
|
|
|
|
|
0
|
print qq{command: $cmd\n}; |
34
|
0
|
|
|
|
|
0
|
print qq{stdout:\n$stdout\n}; |
35
|
0
|
0
|
|
|
|
0
|
print qq{stderr:\n$stderr\n} if (defined $stderr); |
36
|
0
|
|
|
|
|
0
|
print qq{rc: $rc\n}; |
37
|
0
|
|
|
|
|
0
|
print qq{signal: $signal\n}; |
38
|
0
|
|
|
|
|
0
|
print qq{coredump: $coredump\n}; |
39
|
0
|
|
|
|
|
0
|
print qq{rv: $rv\n}; |
40
|
|
|
|
|
|
|
} |
41
|
1
|
|
|
|
|
27
|
return ($rv, $stdout, $stderr); |
42
|
|
|
|
|
|
|
} else { |
43
|
0
|
|
|
|
|
|
my $rc = open(CMD, "$cmd 2>&1 |"); |
44
|
0
|
0
|
|
|
|
|
if(defined $rc) { |
45
|
0
|
|
|
|
|
|
my $stdout = ''; |
46
|
0
|
|
|
|
|
|
while() { |
47
|
0
|
|
|
|
|
|
$stdout .= $_; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
close CMD; |
50
|
0
|
|
|
|
|
|
return (1, $stdout, ''); |
51
|
|
|
|
|
|
|
} else { |
52
|
0
|
|
|
|
|
|
return (0, '', $!); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
62
|
|
|
|
|
|
|
__END__ |