config root man

Current Path : /usr/opt/perl530/man/man3/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //usr/opt/perl530/man/man3/IPC::Cmd.3

.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "IPC::Cmd 3"
.TH IPC::Cmd 3 "2019-10-24" "perl v5.30.2" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
IPC::Cmd \- finding and running system commands made easy
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\&    use IPC::Cmd qw[can_run run run_forked];
\&
\&    my $full_path = can_run(\*(Aqwget\*(Aq) or warn \*(Aqwget is not installed!\*(Aq;
\&
\&    ### commands can be arrayrefs or strings ###
\&    my $cmd = "$full_path \-b theregister.co.uk";
\&    my $cmd = [$full_path, \*(Aq\-b\*(Aq, \*(Aqtheregister.co.uk\*(Aq];
\&
\&    ### in scalar context ###
\&    my $buffer;
\&    if( scalar run( command => $cmd,
\&                    verbose => 0,
\&                    buffer  => \e$buffer,
\&                    timeout => 20 )
\&    ) {
\&        print "fetched webpage successfully: $buffer\en";
\&    }
\&
\&
\&    ### in list context ###
\&    my( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) =
\&            run( command => $cmd, verbose => 0 );
\&
\&    if( $success ) {
\&        print "this is what the command printed:\en";
\&        print join "", @$full_buf;
\&    }
\&
\&    ### run_forked example ###
\&    my $result = run_forked("$full_path \-q \-O \- theregister.co.uk", {\*(Aqtimeout\*(Aq => 20});
\&    if ($result\->{\*(Aqexit_code\*(Aq} eq 0 && !$result\->{\*(Aqtimeout\*(Aq}) {
\&        print "this is what wget returned:\en";
\&        print $result\->{\*(Aqstdout\*(Aq};
\&    }
\&
\&    ### check for features
\&    print "IPC::Open3 available: "  . IPC::Cmd\->can_use_ipc_open3;
\&    print "IPC::Run available: "    . IPC::Cmd\->can_use_ipc_run;
\&    print "Can capture buffer: "    . IPC::Cmd\->can_capture_buffer;
\&
\&    ### don\*(Aqt have IPC::Cmd be verbose, ie don\*(Aqt print to stdout or
\&    ### stderr when running commands \-\- default is \*(Aq0\*(Aq
\&    $IPC::Cmd::VERBOSE = 0;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
IPC::Cmd allows you to run commands platform independently,
interactively if desired, but have them still work.
.PP
The \f(CW\*(C`can_run\*(C'\fR function can tell you if a certain binary is installed
and if so where, whereas the \f(CW\*(C`run\*(C'\fR function can actually execute any
of the commands you give it and give you a clear return value, as well
as adhere to your verbosity settings.
.SH "CLASS METHODS"
.IX Header "CLASS METHODS"
.ie n .SS "$ipc_run_version = IPC::Cmd\->can_use_ipc_run( [\s-1VERBOSE\s0] )"
.el .SS "\f(CW$ipc_run_version\fP = IPC::Cmd\->can_use_ipc_run( [\s-1VERBOSE\s0] )"
.IX Subsection "$ipc_run_version = IPC::Cmd->can_use_ipc_run( [VERBOSE] )"
Utility function that tells you if \f(CW\*(C`IPC::Run\*(C'\fR is available.
If the \f(CW\*(C`verbose\*(C'\fR flag is passed, it will print diagnostic messages
if IPC::Run can not be found or loaded.
.ie n .SS "$ipc_open3_version = IPC::Cmd\->can_use_ipc_open3( [\s-1VERBOSE\s0] )"
.el .SS "\f(CW$ipc_open3_version\fP = IPC::Cmd\->can_use_ipc_open3( [\s-1VERBOSE\s0] )"
.IX Subsection "$ipc_open3_version = IPC::Cmd->can_use_ipc_open3( [VERBOSE] )"
Utility function that tells you if \f(CW\*(C`IPC::Open3\*(C'\fR is available.
If the verbose flag is passed, it will print diagnostic messages
if \f(CW\*(C`IPC::Open3\*(C'\fR can not be found or loaded.
.ie n .SS "$bool = IPC::Cmd\->can_capture_buffer"
.el .SS "\f(CW$bool\fP = IPC::Cmd\->can_capture_buffer"
.IX Subsection "$bool = IPC::Cmd->can_capture_buffer"
Utility function that tells you if \f(CW\*(C`IPC::Cmd\*(C'\fR is capable of
capturing buffers in it's current configuration.
.ie n .SS "$bool = IPC::Cmd\->can_use_run_forked"
.el .SS "\f(CW$bool\fP = IPC::Cmd\->can_use_run_forked"
.IX Subsection "$bool = IPC::Cmd->can_use_run_forked"
Utility function that tells you if \f(CW\*(C`IPC::Cmd\*(C'\fR is capable of
providing \f(CW\*(C`run_forked\*(C'\fR on the current platform.
.SH "FUNCTIONS"
.IX Header "FUNCTIONS"
.ie n .SS "$path = can_run( \s-1PROGRAM\s0 );"
.el .SS "\f(CW$path\fP = can_run( \s-1PROGRAM\s0 );"
.IX Subsection "$path = can_run( PROGRAM );"
\&\f(CW\*(C`can_run\*(C'\fR takes only one argument: the name of a binary you wish
to locate. \f(CW\*(C`can_run\*(C'\fR works much like the unix binary \f(CW\*(C`which\*(C'\fR or the bash
command \f(CW\*(C`type\*(C'\fR, which scans through your path, looking for the requested
binary.
.PP
Unlike \f(CW\*(C`which\*(C'\fR and \f(CW\*(C`type\*(C'\fR, this function is platform independent and
will also work on, for example, Win32.
.PP
If called in a scalar context it will return the full path to the binary
you asked for if it was found, or \f(CW\*(C`undef\*(C'\fR if it was not.
.PP
If called in a list context and the global variable \f(CW$INSTANCES\fR is a true
value, it will return a list of the full paths to instances
of the binary where found in \f(CW\*(C`PATH\*(C'\fR, or an empty list if it was not found.
.ie n .SS "$ok | ($ok, $err, $full_buf, $stdout_buff, $stderr_buff) = run( command => \s-1COMMAND,\s0 [verbose => \s-1BOOL,\s0 buffer => \e$SCALAR, timeout => \s-1DIGIT\s0] );"
.el .SS "\f(CW$ok\fP | ($ok, \f(CW$err\fP, \f(CW$full_buf\fP, \f(CW$stdout_buff\fP, \f(CW$stderr_buff\fP) = run( command => \s-1COMMAND,\s0 [verbose => \s-1BOOL,\s0 buffer => \e$SCALAR, timeout => \s-1DIGIT\s0] );"
.IX Subsection "$ok | ($ok, $err, $full_buf, $stdout_buff, $stderr_buff) = run( command => COMMAND, [verbose => BOOL, buffer => $SCALAR, timeout => DIGIT] );"
\&\f(CW\*(C`run\*(C'\fR takes 4 arguments:
.IP "command" 4
.IX Item "command"
This is the command to execute. It may be either a string or an array
reference.
This is a required argument.
.Sp
See \*(L"Caveats\*(R" for remarks on how commands are parsed and their
limitations.
.IP "verbose" 4
.IX Item "verbose"
This controls whether all output of a command should also be printed
to \s-1STDOUT/STDERR\s0 or should only be trapped in buffers (\s-1NOTE:\s0 buffers
require IPC::Run to be installed, or your system able to work with
IPC::Open3).
.Sp
It will default to the global setting of \f(CW$IPC::Cmd::VERBOSE\fR,
which by default is 0.
.IP "buffer" 4
.IX Item "buffer"
This will hold all the output of a command. It needs to be a reference
to a scalar.
Note that this will hold both the \s-1STDOUT\s0 and \s-1STDERR\s0 messages, and you
have no way of telling which is which.
If you require this distinction, run the \f(CW\*(C`run\*(C'\fR command in list context
and inspect the individual buffers.
.Sp
Of course, this requires that the underlying call supports buffers. See
the note on buffers above.
.IP "timeout" 4
.IX Item "timeout"
Sets the maximum time the command is allowed to run before aborting,
using the built-in \f(CW\*(C`alarm()\*(C'\fR call. If the timeout is triggered, the
\&\f(CW\*(C`errorcode\*(C'\fR in the return value will be set to an object of the
\&\f(CW\*(C`IPC::Cmd::TimeOut\*(C'\fR class. See the \*(L"error message\*(R" section below for
details.
.Sp
Defaults to \f(CW0\fR, meaning no timeout is set.
.PP
\&\f(CW\*(C`run\*(C'\fR will return a simple \f(CW\*(C`true\*(C'\fR or \f(CW\*(C`false\*(C'\fR when called in scalar
context.
In list context, you will be returned a list of the following items:
.IP "success" 4
.IX Item "success"
A simple boolean indicating if the command executed without errors or
not.
.IP "error message" 4
.IX Item "error message"
If the first element of the return value (\f(CW\*(C`success\*(C'\fR) was 0, then some
error occurred. This second element is the error message the command
you requested exited with, if available. This is generally a pretty
printed value of \f(CW$?\fR or \f(CW$@\fR. See \f(CW\*(C`perldoc perlvar\*(C'\fR for details on
what they can contain.
If the error was a timeout, the \f(CW\*(C`error message\*(C'\fR will be prefixed with
the string \f(CW\*(C`IPC::Cmd::TimeOut\*(C'\fR, the timeout class.
.IP "full_buffer" 4
.IX Item "full_buffer"
This is an array reference containing all the output the command
generated.
Note that buffers are only available if you have IPC::Run installed,
or if your system is able to work with IPC::Open3 \*(-- see below).
Otherwise, this element will be \f(CW\*(C`undef\*(C'\fR.
.IP "out_buffer" 4
.IX Item "out_buffer"
This is an array reference containing all the output sent to \s-1STDOUT\s0 the
command generated. The notes from \*(L"full_buffer\*(R" apply.
.IP "error_buffer" 4
.IX Item "error_buffer"
This is an arrayreference containing all the output sent to \s-1STDERR\s0 the
command generated. The notes from \*(L"full_buffer\*(R" apply.
.PP
See the \*(L"\s-1HOW IT WORKS\*(R"\s0 section below to see how \f(CW\*(C`IPC::Cmd\*(C'\fR decides
what modules or function calls to use when issuing a command.
.ie n .SS "$hashref = run_forked( \s-1COMMAND,\s0 { child_stdin => \s-1SCALAR,\s0 timeout => \s-1DIGIT,\s0 stdout_handler => \s-1CODEREF,\s0 stderr_handler => \s-1CODEREF\s0} );"
.el .SS "\f(CW$hashref\fP = run_forked( \s-1COMMAND,\s0 { child_stdin => \s-1SCALAR,\s0 timeout => \s-1DIGIT,\s0 stdout_handler => \s-1CODEREF,\s0 stderr_handler => \s-1CODEREF\s0} );"
.IX Subsection "$hashref = run_forked( COMMAND, { child_stdin => SCALAR, timeout => DIGIT, stdout_handler => CODEREF, stderr_handler => CODEREF} );"
\&\f(CW\*(C`run_forked\*(C'\fR is used to execute some program or a coderef,
optionally feed it with some input, get its return code
and output (both stdout and stderr into separate buffers).
In addition, it allows to terminate the program
if it takes too long to finish.
.PP
The important and distinguishing feature of run_forked
is execution timeout which at first seems to be
quite a simple task but if you think
that the program which you're spawning
might spawn some children itself (which
in their turn could do the same and so on)
it turns out to be not a simple issue.
.PP
\&\f(CW\*(C`run_forked\*(C'\fR is designed to survive and
successfully terminate almost any long running task,
even a fork bomb in case your system has the resources
to survive during given timeout.
.PP
This is achieved by creating separate watchdog process
which spawns the specified program in a separate
process session and supervises it: optionally
feeds it with input, stores its exit code,
stdout and stderr, terminates it in case
it runs longer than specified.
.PP
Invocation requires the command to be executed or a coderef and optionally a hashref of options:
.ie n .IP """timeout""" 4
.el .IP "\f(CWtimeout\fR" 4
.IX Item "timeout"
Specify in seconds how long to run the command before it is killed with \s-1SIG_KILL\s0 (9),
which effectively terminates it and all of its children (direct or indirect).
.ie n .IP """child_stdin""" 4
.el .IP "\f(CWchild_stdin\fR" 4
.IX Item "child_stdin"
Specify some text that will be passed into the \f(CW\*(C`STDIN\*(C'\fR of the executed program.
.ie n .IP """stdout_handler""" 4
.el .IP "\f(CWstdout_handler\fR" 4
.IX Item "stdout_handler"
Coderef of a subroutine to call when a portion of data is received on
\&\s-1STDOUT\s0 from the executing program.
.ie n .IP """stderr_handler""" 4
.el .IP "\f(CWstderr_handler\fR" 4
.IX Item "stderr_handler"
Coderef of a subroutine to call when a portion of data is received on
\&\s-1STDERR\s0 from the executing program.
.ie n .IP """wait_loop_callback""" 4
.el .IP "\f(CWwait_loop_callback\fR" 4
.IX Item "wait_loop_callback"
Coderef of a subroutine to call inside of the main waiting loop
(while \f(CW\*(C`run_forked\*(C'\fR waits for the external to finish or fail).
It is useful to stop running external process before it ends
by itself, e.g.
.Sp
.Vb 8
\&  my $r = run_forked("some external command", {
\&          \*(Aqwait_loop_callback\*(Aq => sub {
\&          if (condition) {
\&              kill(1, $$);
\&          }
\&          },
\&          \*(Aqterminate_on_signal\*(Aq => \*(AqHUP\*(Aq,
\&          });
.Ve
.Sp
Combined with \f(CW\*(C`stdout_handler\*(C'\fR and \f(CW\*(C`stderr_handler\*(C'\fR allows terminating
external command based on its output. Could also be used as a timer
without engaging with alarm (signals).
.Sp
Remember that this code could be called every millisecond (depending
on the output which external command generates), so try to make it
as lightweight as possible.
.ie n .IP """discard_output""" 4
.el .IP "\f(CWdiscard_output\fR" 4
.IX Item "discard_output"
Discards the buffering of the standard output and standard errors for return by \fBrun_forked()\fR.
With this option you have to use the std*_handlers to read what the command outputs.
Useful for commands that send a lot of output.
.ie n .IP """terminate_on_parent_sudden_death""" 4
.el .IP "\f(CWterminate_on_parent_sudden_death\fR" 4
.IX Item "terminate_on_parent_sudden_death"
Enable this option if you wish all spawned processes to be killed if the initially spawned
process (the parent) is killed or dies without waiting for child processes.
.PP
\&\f(CW\*(C`run_forked\*(C'\fR will return a \s-1HASHREF\s0 with the following keys:
.ie n .IP """exit_code""" 4
.el .IP "\f(CWexit_code\fR" 4
.IX Item "exit_code"
The exit code of the executed program.
.ie n .IP """timeout""" 4
.el .IP "\f(CWtimeout\fR" 4
.IX Item "timeout"
The number of seconds the program ran for before being terminated, or 0 if no timeout occurred.
.ie n .IP """stdout""" 4
.el .IP "\f(CWstdout\fR" 4
.IX Item "stdout"
Holds the standard output of the executed command (or empty string if
there was no \s-1STDOUT\s0 output or if \f(CW\*(C`discard_output\*(C'\fR was used; it's always defined!)
.ie n .IP """stderr""" 4
.el .IP "\f(CWstderr\fR" 4
.IX Item "stderr"
Holds the standard error of the executed command (or empty string if
there was no \s-1STDERR\s0 output or if \f(CW\*(C`discard_output\*(C'\fR was used; it's always defined!)
.ie n .IP """merged""" 4
.el .IP "\f(CWmerged\fR" 4
.IX Item "merged"
Holds the standard output and error of the executed command merged into one stream
(or empty string if there was no output at all or if \f(CW\*(C`discard_output\*(C'\fR was used; it's always defined!)
.ie n .IP """err_msg""" 4
.el .IP "\f(CWerr_msg\fR" 4
.IX Item "err_msg"
Holds some explanation in the case of an error.
.ie n .SS "$q = \s-1QUOTE\s0"
.el .SS "\f(CW$q\fP = \s-1QUOTE\s0"
.IX Subsection "$q = QUOTE"
Returns the character used for quoting strings on this platform. This is
usually a \f(CW\*(C`\*(Aq\*(C'\fR (single quote) on most systems, but some systems use different
quotes. For example, \f(CW\*(C`Win32\*(C'\fR uses \f(CW\*(C`"\*(C'\fR (double quote).
.PP
You can use it as follows:
.PP
.Vb 2
\&  use IPC::Cmd qw[run QUOTE];
\&  my $cmd = q[echo ] . QUOTE . q[foo bar] . QUOTE;
.Ve
.PP
This makes sure that \f(CW\*(C`foo bar\*(C'\fR is treated as a string, rather than two
separate arguments to the \f(CW\*(C`echo\*(C'\fR function.
.SH "HOW IT WORKS"
.IX Header "HOW IT WORKS"
\&\f(CW\*(C`run\*(C'\fR will try to execute your command using the following logic:
.IP "\(bu" 4
If you have \f(CW\*(C`IPC::Run\*(C'\fR installed, and the variable \f(CW$IPC::Cmd::USE_IPC_RUN\fR
is set to true (See the \*(L"Global Variables\*(R" section) use that to execute
the command. You will have the full output available in buffers, interactive commands
are sure to work  and you are guaranteed to have your verbosity
settings honored cleanly.
.IP "\(bu" 4
Otherwise, if the variable \f(CW$IPC::Cmd::USE_IPC_OPEN3\fR is set to true
(See the \*(L"Global Variables\*(R" section), try to execute the command using
IPC::Open3. Buffers will be available on all platforms,
interactive commands will still execute cleanly, and also your verbosity
settings will be adhered to nicely;
.IP "\(bu" 4
Otherwise, if you have the \f(CW\*(C`verbose\*(C'\fR argument set to true, we fall back
to a simple \f(CW\*(C`system()\*(C'\fR call. We cannot capture any buffers, but
interactive commands will still work.
.IP "\(bu" 4
Otherwise we will try and temporarily redirect \s-1STDERR\s0 and \s-1STDOUT,\s0 do a
\&\f(CW\*(C`system()\*(C'\fR call with your command and then re-open \s-1STDERR\s0 and \s-1STDOUT.\s0
This is the method of last resort and will still allow you to execute
your commands cleanly. However, no buffers will be available.
.SH "Global Variables"
.IX Header "Global Variables"
The behaviour of IPC::Cmd can be altered by changing the following
global variables:
.ie n .SS "$IPC::Cmd::VERBOSE"
.el .SS "\f(CW$IPC::Cmd::VERBOSE\fP"
.IX Subsection "$IPC::Cmd::VERBOSE"
This controls whether IPC::Cmd will print any output from the
commands to the screen or not. The default is 0.
.ie n .SS "$IPC::Cmd::USE_IPC_RUN"
.el .SS "\f(CW$IPC::Cmd::USE_IPC_RUN\fP"
.IX Subsection "$IPC::Cmd::USE_IPC_RUN"
This variable controls whether IPC::Cmd will try to use IPC::Run
when available and suitable.
.ie n .SS "$IPC::Cmd::USE_IPC_OPEN3"
.el .SS "\f(CW$IPC::Cmd::USE_IPC_OPEN3\fP"
.IX Subsection "$IPC::Cmd::USE_IPC_OPEN3"
This variable controls whether IPC::Cmd will try to use IPC::Open3
when available and suitable. Defaults to true.
.ie n .SS "$IPC::Cmd::WARN"
.el .SS "\f(CW$IPC::Cmd::WARN\fP"
.IX Subsection "$IPC::Cmd::WARN"
This variable controls whether run-time warnings should be issued, like
the failure to load an \f(CW\*(C`IPC::*\*(C'\fR module you explicitly requested.
.PP
Defaults to true. Turn this off at your own risk.
.ie n .SS "$IPC::Cmd::INSTANCES"
.el .SS "\f(CW$IPC::Cmd::INSTANCES\fP"
.IX Subsection "$IPC::Cmd::INSTANCES"
This variable controls whether \f(CW\*(C`can_run\*(C'\fR will return all instances of
the binary it finds in the \f(CW\*(C`PATH\*(C'\fR when called in a list context.
.PP
Defaults to false, set to true to enable the described behaviour.
.ie n .SS "$IPC::Cmd::ALLOW_NULL_ARGS"
.el .SS "\f(CW$IPC::Cmd::ALLOW_NULL_ARGS\fP"
.IX Subsection "$IPC::Cmd::ALLOW_NULL_ARGS"
This variable controls whether \f(CW\*(C`run\*(C'\fR will remove any empty/null arguments
it finds in command arguments.
.PP
Defaults to false, so it will remove null arguments. Set to true to allow
them.
.SH "Caveats"
.IX Header "Caveats"
.IP "Whitespace and IPC::Open3 / \fBsystem()\fR" 4
.IX Item "Whitespace and IPC::Open3 / system()"
When using \f(CW\*(C`IPC::Open3\*(C'\fR or \f(CW\*(C`system\*(C'\fR, if you provide a string as the
\&\f(CW\*(C`command\*(C'\fR argument, it is assumed to be appropriately escaped. You can
use the \f(CW\*(C`QUOTE\*(C'\fR constant to use as a portable quote character (see above).
However, if you provide an array reference, special rules apply:
.Sp
If your command contains \fBspecial characters\fR (< > | &), it will
be internally stringified before executing the command, to avoid that these
special characters are escaped and passed as arguments instead of retaining
their special meaning.
.Sp
However, if the command contained arguments that contained whitespace,
stringifying the command would lose the significance of the whitespace.
Therefore, \f(CW\*(C`IPC::Cmd\*(C'\fR will quote any arguments containing whitespace in your
command if the command is passed as an arrayref and contains special characters.
.IP "Whitespace and IPC::Run" 4
.IX Item "Whitespace and IPC::Run"
When using \f(CW\*(C`IPC::Run\*(C'\fR, if you provide a string as the \f(CW\*(C`command\*(C'\fR argument,
the string will be split on whitespace to determine the individual elements
of your command. Although this will usually just Do What You Mean, it may
break if you have files or commands with whitespace in them.
.Sp
If you do not wish this to happen, you should provide an array
reference, where all parts of your command are already separated out.
Note however, if there are extra or spurious whitespaces in these parts,
the parser or underlying code may not interpret it correctly, and
cause an error.
.Sp
Example:
The following code
.Sp
.Vb 1
\&    gzip \-cdf foo.tar.gz | tar \-xf \-
.Ve
.Sp
should either be passed as
.Sp
.Vb 1
\&    "gzip \-cdf foo.tar.gz | tar \-xf \-"
.Ve
.Sp
or as
.Sp
.Vb 1
\&    [\*(Aqgzip\*(Aq, \*(Aq\-cdf\*(Aq, \*(Aqfoo.tar.gz\*(Aq, \*(Aq|\*(Aq, \*(Aqtar\*(Aq, \*(Aq\-xf\*(Aq, \*(Aq\-\*(Aq]
.Ve
.Sp
But take care not to pass it as, for example
.Sp
.Vb 1
\&    [\*(Aqgzip \-cdf foo.tar.gz\*(Aq, \*(Aq|\*(Aq, \*(Aqtar \-xf \-\*(Aq]
.Ve
.Sp
Since this will lead to issues as described above.
.IP "\s-1IO\s0 Redirect" 4
.IX Item "IO Redirect"
Currently it is too complicated to parse your command for \s-1IO\s0
redirections. For capturing \s-1STDOUT\s0 or \s-1STDERR\s0 there is a work around
however, since you can just inspect your buffers for the contents.
.IP "Interleaving \s-1STDOUT/STDERR\s0" 4
.IX Item "Interleaving STDOUT/STDERR"
Neither IPC::Run nor IPC::Open3 can interleave \s-1STDOUT\s0 and \s-1STDERR.\s0 For short
bursts of output from a program, e.g. this sample,
.Sp
.Vb 3
\&    for ( 1..4 ) {
\&        $_ % 2 ? print STDOUT $_ : print STDERR $_;
\&    }
.Ve
.Sp
IPC::[Run|Open3] will first read all of \s-1STDOUT,\s0 then all of \s-1STDERR,\s0 meaning
the output looks like '13' on \s-1STDOUT\s0 and '24' on \s-1STDERR,\s0 instead of
.Sp
.Vb 4
\&    1
\&    2
\&    3
\&    4
.Ve
.Sp
This has been recorded in rt.cpan.org as bug #37532: Unable to interleave
\&\s-1STDOUT\s0 and \s-1STDERR.\s0
.SH "See Also"
.IX Header "See Also"
IPC::Run, IPC::Open3
.SH "ACKNOWLEDGEMENTS"
.IX Header "ACKNOWLEDGEMENTS"
Thanks to James Mastros and Martijn van der Streek for their
help in getting IPC::Open3 to behave nicely.
.PP
Thanks to Petya Kohts for the \f(CW\*(C`run_forked\*(C'\fR code.
.SH "BUG REPORTS"
.IX Header "BUG REPORTS"
Please report bugs or other issues to <bug\-ipc\-cmd@rt.cpan.org>.
.SH "AUTHOR"
.IX Header "AUTHOR"
Original author: Jos Boumans <kane@cpan.org>.
Current maintainer: Chris Williams <bingos@cpan.org>.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
This library is free software; you may redistribute and/or modify it
under the same terms as Perl itself.

Man Man