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
	 
	
	
	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. ParametersThrows
					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
					$cmdstring$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() Parameters
					$filtertype$filter PCRE regular expression
$cmdtype$cmd
$cwdtype$cwd
Returns | 
	
		| 
			 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
					$cmdstring$cmd
$cwdstring$cwd
$filterstring$filter Optional regular expressions filter to restrict the input to only
certain lines.
Returns | 
	
		| 
			 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
					$cmdstring$cmd
$inputresource|string$input The input for the program.
$cwdstring$cwd The directory to work in while executing.
$filterReturns | 
	
		| 
			 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. Save the table to a temporary file, sends it to cron, and deletes the
temporary file. Parameters
					$crontabstring$crontab The new contents of the updated cron table
 | 
	
	
	Constants summary
	
		| integer | 
				DEBUG
		 | 0 |  | 
	
	
	Properties summary
	
		| 
			public  
			array
		 | $cmd | array() |  | 
	
		| 
			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-compliantoperating 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, |