IPC::ShellCmd::Generic - Chain a generic wrapper-type command


IPC-ShellCmd documentation Contained in the IPC-ShellCmd distribution.

Index


Code Index:

NAME

Top

  IPC::ShellCmd::Generic - Chain a generic wrapper-type command

SYNOPSIS

Top

    $cmd_obj->chain_prog(
        IPC::ShellCmd::Generic->new(
	        Prog => 'time',
			Args => ["-p"],
        )
    );




DESCRIPTION

Top

IPC::ShellCmd::Generic->new(Prog => $prog, [$opt => $val, ...])

The only external method for this is the constructor. This sets up the various arguments that are going to be used to generate the command-line.

Other methods on this are used by IPC::ShellCmd, but it should only ever be used inside of the chain_prog method on a IPC::ShellCmd object.

Prog REQUIRED

The program to run, eg. tsocks, socksify, time

Args

A set of arguments to the program before passing the command and args

BUGS

Top

I don't know of any, but that doesn't mean they're not there.

AUTHORS

Top

See IPC::ShellCmd for authors.

LICENSE

Top

See IPC::ShellCmd for the license.


IPC-ShellCmd documentation Contained in the IPC-ShellCmd distribution.
package IPC::ShellCmd::Generic;

use strict;
use Carp qw(croak);
use base qw(IPC::ShellCmd::ShBase);

sub new {
    my $package = shift;
    my %args = @_;

    croak "Must specify a Prog argument"
        unless defined $args{Prog};

    my $self = bless { args => \%args }, $package;

    return $self;
}

sub chain {
    my $self = shift;
    my $cmd = shift;
    my $args = shift;

    my $cmd_string = $self->generate_sh_cmd($cmd, $args);

    my @generic = ($self->{args}->{Prog});

    push (@generic, @{$self->{args}->{Args}})
	    if(defined $self->{args}->{Args});

    push (@generic, "sh", "-c", $cmd_string);

    return @generic;
}

1;