Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • AppFileUtil
  • CommandUtil
  • CrontabUtil
  • EncryptUtil
  • FileUtil
  • Overview
  • Package
  • Class
  • Tree

Class CommandUtil

Stand-alone class for running more advanced command line programs.

Provides a wrapper/shortcut object for running commands using proc_open.

This should ideally permit chaining of programs via pipes. An example, on Unix-like systems:

$cmd->run('ps aux')->pipeTo('awk \'/foo/ {print $2}\'')->pipeTo('kill')->complete();

The above would send SIGTERM to all processes matching "foo". However, this is not yet possible due to a "bug" in PHP: http://stackoverflow.com/questions/6014761/proper-shell-execution-in-php

Package: application\components\util
Author: Demitri Morgan <demitri@x2engine.com>
Located at x2engine/protected/components/util/CommandUtil.php
Methods summary
public
# __construct( )

Gathers some information about the operating environment.

Gathers some information about the operating environment.

public
# close( type $ind )

Closes a process and throws an exception if it exited with error code.

Closes a process and throws an exception if it exited with error code.

Parameters

$ind
type
$ind

Throws

Exception
public boolean
# cmdExists( string $cmd )

Returns true or false based on whether the named command exists on the system.

Returns true or false based on whether the named command exists on the system.

Parameters

$cmd
string
$cmd Name of the command

Returns

boolean
public
# complete( )

Closes all processes and returns the return value of proc_close from the last one.

Closes all processes and returns the return value of proc_close from the last one.

public
# debug( mixed $msg, mixed $lvl = 1 )
public integer
# nProc( )

Returns the current number of subprocesses.

Returns the current number of subprocesses.

Returns

integer
public string
# output( )

Returns the output of the last command and closes/clears all processes.

Returns the output of the last command and closes/clears all processes.

Returns

string
public CommandUtil
# pipeFilteredTo( type $filter, type $cmd, type $cwd = null )

Wrapper for CommandUtil::pipeTo()

Wrapper for CommandUtil::pipeTo()

Parameters

$filter
type
$filter PCRE regular expression
$cmd
type
$cmd
$cwd
type
$cwd

Returns

CommandUtil
public CommandUtil
# pipeTo( string $cmd, string $cwd = null, string $filter = null )

Takes the output of the last comand and pipes it to a new command

Takes the output of the last comand and pipes it to a new command

Parameters

$cmd
string
$cmd
$cwd
string
$cwd
$filter
string
$filter Optional regular expressions filter to restrict the input to only certain lines.

Returns

CommandUtil
public CommandUtil
# run( string $cmd, resource|string $input = null, string $cwd = null, mixed $filter = null )

Runs a command on the command line.

Runs a command on the command line.

Parameters

$cmd
string
$cmd
$input
resource|string
$input The input for the program.
$cwd
string
$cwd The directory to work in while executing.
$filter

Returns

CommandUtil
public string
# loadCrontab( )

Loads and returns the cron table. Performs environment check first.

Loads and returns the cron table. Performs environment check first.

Returns

string
public
# saveCrontab( string $crontab )

Saves the cron table.

Saves the cron table.

Save the table to a temporary file, sends it to cron, and deletes the temporary file.

Parameters

$crontab
string
$crontab The new contents of the updated cron table
Constants summary
integer DEBUG 0
#
Properties summary
public array $cmd array()
#

Subprocess commands

Subprocess commands

public type $inputs array()
#

Saves input given to each program, for debugging/examination purposes

Saves input given to each program, for debugging/examination purposes

public mixed $lastReturnCode
#

The status of the last process that was completed.

The status of the last process that was completed.

public string $os
#

Operating system; a keyword "posix" for posix-compliant
operating systems like Linux/Unix, or "dos" for Windows-based systems.

Operating system; a keyword "posix" for posix-compliant operating systems like Linux/Unix, or "dos" for Windows-based systems.

public array $pipeline array()
#

The stack of subprocesses inputs/outputs currently executing.

The stack of subprocesses inputs/outputs currently executing.

Each value corresponds to an index in CommandUtil::$processes.

public array $procArrays array( 'cmd', 'inputs', 'pipeline', 'processes', )
#
public array $processes array()
#

All subprocess handles of the current program,

All subprocess handles of the current program,

X2CRM Documentation API documentation generated by ApiGen 2.8.0