PHP code example of gonzalo123 / sh

1. Go to this page and download the library: Download gonzalo123/sh library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gonzalo123 / sh example snippets



error_reporting(-1);

// 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
});