<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.ssh2.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.ssh2-exec.php',
    1 => 'ssh2_exec',
    2 => 'Execute a command on a remote server',
  ),
  'up' => 
  array (
    0 => 'ref.ssh2.php',
    1 => 'SSH2 Функції',
  ),
  'prev' => 
  array (
    0 => 'function.ssh2-disconnect.php',
    1 => 'ssh2_disconnect',
  ),
  'next' => 
  array (
    0 => 'function.ssh2-fetch-stream.php',
    1 => 'ssh2_fetch_stream',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/ssh2/functions/ssh2-exec.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.ssh2-exec" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ssh2_exec</h1>
  <p class="verinfo">(PECL ssh2 &gt;= 0.9.0)</p><p class="refpurpose"><span class="refname">ssh2_exec</span> &mdash; <span class="dc-title">Execute a command on a remote server</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ssh2-exec-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ssh2_exec</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$session</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$command</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$pty</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$env</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$width</code><span class="initializer"> = 80</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$height</code><span class="initializer"> = 25</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$width_height_type</code><span class="initializer"> = SSH2_TERM_UNIT_CHARS</span></span><br>): <span class="type"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Execute a command at the remote end and allocate a channel for it.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ssh2-exec-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">session</code></dt>
     <dd>
      <p class="para">
       An SSH connection link identifier, obtained from a call to
       <span class="function"><a href="function.ssh2-connect.php" class="function">ssh2_connect()</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">command</code></dt>
     <dd>
      <p class="para">
      </p>
     </dd>
    
    
     <dt><code class="parameter">pty</code></dt>
     <dd>
      <p class="para">
      </p>
     </dd>
    
    
     <dt><code class="parameter">env</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">env</code> may be passed as an associative array of
       name/value pairs to set in the target environment.
      </p>
     </dd>
    
    
     <dt><code class="parameter">width</code></dt>
     <dd>
      <p class="para">
       Width of the virtual terminal.
      </p>
     </dd>
    
    
     <dt><code class="parameter">height</code></dt>
     <dd>
      <p class="para">
       Height of the virtual terminal.
      </p>
     </dd>
    
    
     <dt><code class="parameter">width_height_type</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">width_height_type</code> should be one of
       <strong><code><a href="ssh2.constants.php#constant.ssh2-term-unit-chars">SSH2_TERM_UNIT_CHARS</a></code></strong> or
       <strong><code><a href="ssh2.constants.php#constant.ssh2-term-unit-pixels">SSH2_TERM_UNIT_PIXELS</a></code></strong>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ssh2-exec-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns a stream on success або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ssh2-exec-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 Executing a command</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$connection </span><span style="color: #007700">= </span><span style="color: #0000BB">ssh2_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'shell.example.com'</span><span style="color: #007700">, </span><span style="color: #0000BB">22</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ssh2_auth_password</span><span style="color: #007700">(</span><span style="color: #0000BB">$connection</span><span style="color: #007700">, </span><span style="color: #DD0000">'username'</span><span style="color: #007700">, </span><span style="color: #DD0000">'password'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$stream </span><span style="color: #007700">= </span><span style="color: #0000BB">ssh2_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$connection</span><span style="color: #007700">, </span><span style="color: #DD0000">'/usr/local/bin/php -i'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ssh2-exec-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.ssh2-connect.php" class="function" rel="rdfs-seeAlso">ssh2_connect()</a> - Connect to an SSH server</span></li>
    <li><span class="function"><a href="function.ssh2-shell.php" class="function" rel="rdfs-seeAlso">ssh2_shell()</a> - Request an interactive shell</span></li>
    <li><span class="function"><a href="function.ssh2-tunnel.php" class="function" rel="rdfs-seeAlso">ssh2_tunnel()</a> - Open a tunnel through a remote server</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>