| 1 | package YVDHOVE::System; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008000; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | # --------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( execCMD ) ] ); | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} }); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | our @EXPORT = (); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our $VERSION = '1.02'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # --------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | sub execCMD($$$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execCMD: called CC=10 SCAR=34.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | my ($cmd, $captureoutput, $debug) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | print qq{execCMD: $cmd\n} if($debug); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | if ($captureoutput) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use IO::CaptureOutput qw(capture capture_exec qxx); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my ($stdout, $stderr) = capture_exec("$cmd"); | |||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | my $rc = ($? >> 8); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | my $signal = ($? & 127); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | my $coredump = ($? & 128); | |||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | my $rv = ($stderr eq '' && $signal == 0 && $coredump == 0) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$stderr eq "" and $signal == 0 and $coredump == 0
$stderr eq "" and $signal == 0
MC/DC0%0/3
$stderr eq "" and $signal == 0 and $coredump == 0
$stderr eq ""
$signal == 0
$coredump == 0
Truth table25%1/4
A and B and C
A= $stderr eq ""B= $signal == 0C= $coredump == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | if($debug) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | print qq{command: $cmd\n}; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | print qq{stdout:\n$stdout\n}; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | print qq{stderr:\n$stderr\n} if (defined $stderr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | print qq{rc: $rc\n}; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | print qq{signal: $signal\n}; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | print qq{coredump: $coredump\n}; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | print qq{rv: $rv\n}; | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | return ($rv, $stdout, $stderr); | |||||||||||||||||||||||||||||||||||||||||
| 42 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $rc = open(CMD, "$cmd 2>&1 |"); | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if(defined $rc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $stdout = ''; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | while(<CMD>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # --------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 62 | __END__ | ||||||||||||||||||||||||||||||||||||||||||