Wiki

Clone wiki

utm5cabinet_5.3 / Выполнение utm5_payment_tools на удаленном сервере

#!php

$ssh_name='root';
$ssh_password='pass';
$ssh_host='192.168.1.10';
$ssh_port='22';

        $connection = ssh2_connect($ssh_host, $ssh_port);
        if (ssh2_auth_password($connection, $ssh_name, $ssh_password)) {
            $this->logger->info('Успешное соединение по SSH');

            $result = ssh2_exec($connection, '/netup/utm5/bin/utm5_payment_tool' . ' -a' . $account_id . ' -b' . $total . ' -e' .  $billnumber . ' -L payment_comment');

            $errorStream = ssh2_fetch_stream($result, SSH2_STREAM_STDERR);

            // Enable blocking for both streams
            stream_set_blocking($errorStream, true);
            stream_set_blocking($result, true);

            // Whichever of the two below commands is listed first will receive its appropriate output. The second command receives nothing
            $this->logger->info("Output: " . stream_get_contents($result));
            $this->logger->info("Error: " . stream_get_contents($errorStream));

            // Close the streams
            fclose($errorStream);
            fclose($result);

        } else {
            $this->logger->err('Ошибка соединения по SSH');
        }

Updated