Paul Evans > IPC-PerlSSH > IPC::PerlSSH::Library::Run

Download:
IPC-PerlSSH-0.16.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  1
View/Report Bugs
Module Version: 0.16   Source  

NAME ^

IPC::PerlSSH::Library::Run - a library of command running functions for IPC::PerlSSH

SYNOPSIS ^

 use IPC::PerlSSH;

 my $ips = IPC::PerlSSH->new( Host => "over.there" );

 $ips->use_library( "Run", qw( system system_out system_in ) );

 my ( $result, $out ) = $ips->call( "system_out", qw( ip addr ls ) );
 $out == 0 or die "ip failed\n";

 for (split m/\n/, $out ) {
    # some processing here...
 }

 my $result = $ips->call( "system", qw( ip addr add 1.2.3.4/28 dev eth0 ) );

 # To execute a shell command, send a single string
 my $result = $ips->call( "system_in", "1", 
    "echo >/proc/sys/net/ipv4/ip_forward"
 );

DESCRIPTION ^

This module provides a library of functions for executing processes on the remote system. As well as a basic system()-like wrapper, there are also functions for passing data in to the executed process's STDIN stream, reading from its STDOUT stream, or both simultaneously.

Each of these functions will only return once the remote process has exited. If interaction with the process is required while it is running, a remote pipe open may be performed instead using functions in IPC::PerlSSH::Library::IO.

FUNCTIONS ^

The following four functions do not redirect the STDERR stream of the invoked program, allowing it to pass unhindered back through the ssh connection to the local program.

system

Execute a program with the given arguments, returning its exit status.

 my $exitstatus = $ips->call( "system", $path, @args );

To obtain the exit value, use WEXITSTATUS from POSIX.

system_in

Execute a program with the given arguments, passing in a string to its STDIN, and returning its exit status

 my $exitstatus = $ips->call( "system_in", $stdin, $path, @args );

system_out

Execute a program with the given arguments, returning its exit status and what it wrote on STDOUT.

 my ( $exitstatus, $stdout ) = $ips->call( "system_out", $path, @args );

system_inout

Execute a program with the given arguments, passing in a string to its STDIN, and returning its exit status and what it wrote on STDOUT.

 my ( $exitstatus, $stdout ) =
    $ips->call( "system_inout", $stdin, $path, @args )

The following four functions capture the invoked program's STDERR stream.

system_err

Execute a program with the given arguments, returning its exit status and what it wrote on STDERR.

 my ( $exitstatus, $stderr ) = $ips->call( "system_err", $path, @args );

system_inerr

Execute a program with the given arguments, passing in a string to its STDIN, and returning its exit status and what it wrote on STDERR.

 my ( $exitstatus, $stderr ) =
    $ips->call( "system_inerr", $stdin, $path, @args );

system_outerr

Execute a program with the given arguments, returning its exit status and what it wrote on STDOUT and STDERR.

 my ( $exitstatus, $stdout, $stderr ) =
    $ips->call( "system_outerr", $path, @args );

system_inouterr

Execute a program with the given arguments, passing in a string to its STDIN, and returning its exit status and what it wrote on STDOUT and STDERR.

 my ( $exitstatus, $stdout, $stderr ) =
    $ips->call( "system_inouterr", $stdin, $path, @args )

AUTHOR ^

Paul Evans <leonerd@leonerd.org.uk>

syntax highlighting: