|
NAME"IPC::PerlSSH::Library::Run" - a library of command running functions for "IPC::PerlSSH"SYNOPSISuse 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" ); DESCRIPTIONThis 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. FUNCTIONSThe 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.systemExecute 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_inExecute a program with the given arguments, passing in a string to its STDIN, and returning its exit statusmy $exitstatus = $ips->call( "system_in", $stdin, $path, @args ); system_outExecute 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_inoutExecute 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_errExecute 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_inerrExecute 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_outerrExecute 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_inouterrExecute 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 ) AUTHORPaul Evans <leonerd@leonerd.org.uk>
Visit the GSP FreeBSD Man Page Interface. |