Roderick Schertler > Proc-SafePipe-0.01 > Proc::SafePipe

Download:
Proc-SafePipe-0.01.tar.gz

Dependencies

Annotate this POD

Related Modules

File::Find
IPC::Open3
Proc::Simple
Proc::Short
Proc::Reliable
more...
By perlmonks.org
View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Proc::SafePipe - popen() and `` without calling the shell

SYNOPSIS ^

    $fh         = popen_noshell 'r', 'decrypt', $input;
    ($fh, $pid) = popen_noshell 'w', 'ssh', $host, "cat >$output";

    $all_output = backtick_noshell 'decrypt', $input;
    @lines      = backtick_noshell $cmd, @arg;

DESCRIPTION ^

These functions provide a simple way to read from or write to commands which are run without being interpreted by the shell. They croak if there's a system failure, such as a failed fork.

popen_noshell mode command [arg]...

This function is similar to popen() except that the command and its related args are never interpreted by a shell, they are passed to exec() as-is. The mode argument must be 'r' or 'w'.

If called in an array context the return value is a list consisting of the filehandle and the PID of the child. In a scalar context only the filehandle is returned.

backtick_noshell command [arg]...

This function runs the given command with the given args and returns the output, like `` does. The difference is that the arguments are not filtered through a shell, they are exec()ed directly.

The return value is either all the output from the command (if in a scalar context) or a list of the lines gathered from the command (in an array context). The exit status of the command is in $?.

AUTHOR ^

Roderick Schertler <roderick@argon.org>

syntax highlighting: