\MrCrankHank\ConsoleAccessConsoleAccess

Class ConsoleAccess

Summary

Methods
Properties
Constants
__construct()
sudo()
bin()
param()
exec()
getOutput()
getExitStatus()
getBin()
setPreExec()
setPostExec()
getParams()
getStart()
getEnd()
getDuration()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$adapter
$sudo
$pre
$post
$params
$bin
$start
$end
N/A

Properties

$sudo

$sudo : 

Path to the sudo binary

Type

$pre

$pre : 

Store closure which will be executed before the command

Type

$post

$post : 

Store closure which will be executed after the command

Type

$params

$params : array

Save the params

Type

array

$bin

$bin : string

Path to the bin, which should be executed.

Type

string

$start

$start : integer

Unix timestamp of the start of the command exec

Type

integer

$end

$end : integer

Unix timestamp of the end of the command exec

Type

integer

Methods

sudo()

sudo(string  $sudo = '/usr/bin/sudo') : $this

Prepend sudo to the command.

Parameters

string $sudo

Path to the sudo binary

Returns

$this

bin()

bin(  $bin,   $escape = true) : $this

Give a bin to be executed.

You may append parameters using the param() method

Parameters

$bin
$escape

boolean

Returns

$this

param()

param(  $param,   $escape = true) : $this

Append parameters

Parameters

$param
$escape

boolean

Returns

$this

exec()

exec(\Closure|null  $live = null) 

Exec the command on the adapter.

You can pass a closure to capture the live output.

Parameters

\Closure|null $live

Throws

\MrCrankHank\ConsoleAccess\Exceptions\MissingCommandException

getOutput()

getOutput() : mixed

Get full output of the executed command

Returns

mixed

getExitStatus()

getExitStatus() : mixed

Get exit status of the executed command

Returns

mixed

getBin()

getBin() : mixed

Return the given command.

Returns

mixed

setPreExec()

setPreExec(\Closure  $function) 

Set a function which will be executed directly before the command is executed. You can write something into an audit log for example.

The function will receive the command as first parameter.

Parameters

\Closure $function

setPostExec()

setPostExec(\Closure  $function) 

Set a function which will be executed directly after the command was executed. You can write something into an audit log for example.

The function will receive the command as first parameter and the exit status as second one.

Parameters

\Closure $function

getParams()

getParams() : array

Return the parameters.

Returns

array

getStart()

getStart() : integer

Return start timestamp

Returns

integer

getEnd()

getEnd() : integer

Return end timestamp

Returns

integer

getDuration()

getDuration() : integer

Return the duration of command exec.

For simple commands, this might return 0.

Returns

integer