예제 #1
0
파일: Command.php 프로젝트: gonzalo123/sh
 public function doCallback()
 {
     $output = null;
     $process = new Process($this->getCommandString());
     $process->setTimeout($this->sh->getTimeout());
     $process->run(function ($type, $buffer) {
         call_user_func_array($this->lineCallback, array($buffer, $type));
     });
     return;
 }
예제 #2
0
파일: examples.php 프로젝트: gonzalo123/sh
<?php

error_reporting(-1);
// include PSR-0 autoloader
include __DIR__ . '/../vendor/autoload.php';
use Sh\Sh;
// Simple command using factory
echo Sh::factory()->runCommand('notify-send', array('-t', 5000, 'title', 'HOLA'));
// with instance
$sh = new Sh();
echo $sh->ifconfig("eth0");
echo $sh->ls('-latr ~');
echo $sh->ls(array('-latr', '~'));
$sh->tail('-f /var/log/apache2/access.log', function ($buffer) {
    echo $buffer;
});
// chainable commands (baking)
$sh->ssh(array('myserver.com', '-p' => 1393))->whoami();
// executes: ssh myserver.com -p 1393 whoami
$sh->ssh(array('myserver.com', '-p' => 1393))->tail(array("/var/log/dumb_daemon.log", 'n' => 100));
// executes: ssh myserver.com -p 1393 tail /var/log/dumb_daemon.log -n 100
예제 #3
0
<?php

include __DIR__ . '/../vendor/autoload.php';
use FsWatcher\Watcher;
use Sh\Sh;
$directoryToWatch = './';
$sh = new Sh();
$watcher = Watcher::factory($directoryToWatch);
$watcher->registerExtensionToWatch('php');
$watcher->onSave(function ($file) use($sh) {
    echo $sh->php("-l {$file}");
    echo "\n";
});
$watcher->onDelete(function ($file) {
    echo "DELETED: {$file}\n";
});
$watcher->onCreate(function ($file) {
    echo "CREATED: {$file}\n";
});
$watcher->start();