public function exec($cmd, $args = array())
    {
        // Arguments must be safe
        if (!is_array($args)) {
            $args = array($args);
        }
        foreach ($args as $val) {
            if (!is_string($val)) {
                throw new BaseException('You must specify arguments as strings');
            }
            $this->args[] = escapeshellarg($val);
        }

        // Command myst be safe
        $this->cmd = escapeshellcmd($cmd);

        $this->debug('Executing '.$cmd.($this->args ? ' '.implode(' ', $this->args) : ''));
        // Now do the execution
        $this->executeRaw($this->cmd.' '.implode(' ', $this->args));

        return $this;
    }
public function exec($cmd, $args = array())
    {
        // Arguments must be safe
        if (!is_array($args)) {
            $args = array($args);
        }
        foreach ($args as $val) {
            if (!is_string($val)) {
                throw new BaseException('You must specify arguments as strings');
            }
            $this->args[] = escapeshellarg($val);
        }

        // Command myst be safe
        $this->cmd = escapeshellcmd($cmd);

        $this->debug('Executing '.$cmd.($this->args ? ' '.implode(' ', $this->args) : ''));
        // Now do the execution
        $this->executeRaw($this->cmd.' '.implode(' ', $this->args));

        return $this;
    }
public function exec ( $ cmd , $ args = array ( ) ) { // Arguments must be safe if ( ! is_array ( $ args ) ) { $ args = array ( $ args ) ; } foreach ( $ args as $ val ) { if ( ! is_string ( $ val ) ) { throw new BaseException ( 'You must specify arguments as strings' ) ; } $ this -> args [ ] = escapeshellarg ( $ val ) ; } // Command myst be safe $ this -> cmd = escapeshellcmd ( $ cmd ) ; $ this -> debug ( 'Executing ' . $ cmd . ( $ this -> args ? ' ' . implode ( ' ' , $ this -> args ) : '' ) ) ; // Now do the execution $ this -> executeRaw ( $ this -> cmd . ' ' . implode ( ' ' , $ this -> args ) ) ; return $ this ; }
Execute the process and associate with this object.

@param string $cmd  Command to be executed
@param array|string  $args Arguments (strings)

@return self
Execute the process and associate with this object .