mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 22:06:57 +08:00
168 lines
5.9 KiB
HTML
168 lines
5.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Execute a command on a remote server</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.ssh2-exec" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">ssh2_exec</h1>
|
|
<p class="verinfo">(PECL ssh2 >= 0.9.0)</p><p class="refpurpose"><span class="refname">ssh2_exec</span> — <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>
|
|
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$session</code></span>
|
|
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$command</code></span>
|
|
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$pty</code></span>
|
|
[, <span class="methodparam"><span class="type">array</span> <code class="parameter">$env</code></span>
|
|
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$width</code><span class="initializer"> = 80</span></span>
|
|
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$height</code><span class="initializer"> = 25</span></span>
|
|
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$width_height_type</code><span class="initializer"> = SSH2_TERM_UNIT_CHARS</span></span>
|
|
]]]]] ) : <span class="type">resource</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="ssh2_connect.html" 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>SSH2_TERM_UNIT_CHARS</code></strong> or
|
|
<strong><code>SSH2_TERM_UNIT_PIXELS</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>FALSE</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-5616">
|
|
<p><strong>Example #1 Executing a command</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?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">?></span>
|
|
</span>
|
|
</pre></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 class="member"><span class="function"><a href="ssh2_connect.html" class="function" rel="rdfs-seeAlso">ssh2_connect()</a> - Connect to an SSH server</span></li>
|
|
<li class="member"><span class="function"><a href="ssh2_shell.html" class="function" rel="rdfs-seeAlso">ssh2_shell()</a> - Request an interactive shell</span></li>
|
|
<li class="member"><span class="function"><a href="ssh2_tunnel.html" class="function" rel="rdfs-seeAlso">ssh2_tunnel()</a> - Open a tunnel through a remote server</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |