dev-master
9999999-devConsole
MIT
The Requires
by Yagya Chaudhary
0.0.3
0.0.3.0Console
MIT
The Requires
by Yagya Chaudhary
0.0.2
0.0.2.0Console
MIT
The Requires
by Yagya Chaudhary
0.0.1
0.0.1.0Console
MIT
The Requires
by Yagya Chaudhary
Wallogit.com
2017 © Pedro Peláez
Console
Execute command to remote host using SSH Channel., (*1)
require_once __DIR__ . "/vendor/autoload.php"; use Bakhari\Console\Console; use Bakhari\Console\Command; use Bakhari\Console\Streams\FileOutputStream; use PhanAn\Remote\Remote; use Illuminate\Config\Repository as ConsoleConfig;
$console = new Console(new ConsoleConfig([
'host' => '127.0.0.1',
'port' => 22,
'username' => '<username>',
'password' => base64_decode('PHBhc3N3b3JkPg=='),
'auto_login' => false,
'prompt' => '/[\$>]/',
'stdout' => false,
]));
Console's output is sent to stdout by default. Other streams can be added as well. Below we are using FileOutputStream to log the output to /tmp/console, (*2)
$console->pushOutputStream(new FileOutputStream('/tmp/console'));
````
#### Login to Console
If auto_login is disabled, we need to login
```php
$console->login();
To run commands we create a Command Object, and envoke it using run method. Second optional parameter (bool)$dry can be passed for dummy test., (*3)
$console->run(new Command([
'hostname',
'cat /etc/passwd',
]));
Console
MIT
Console
MIT
Console
MIT
Console
MIT