array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.ssh2-exec.php', 1 => 'ssh2_exec', ), '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' => 'ja', 'path' => 'reference/ssh2/functions/ssh2-exec.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PECL ssh2 >= 0.9.0)
ssh2_exec — リモートサーバー上でコマンドを実行する
$session
,$command
,$pty
= ?,$env
= ?,$width
= 80,$height
= 25,$width_height_type
= SSH2_TERM_UNIT_CHARSコマンドをリモートエンドで実行し、チャネルを割り当てます。
session
ssh2_connect() のコールによって取得した SSH 接続リンク ID。
command
pty
env
env
には、
対象となる環境で設定する名前/値のペアを連想配列で渡します。
width
仮想端末の幅。
height
仮想端末の高さ。
width_height_type
width_height_type
は、
SSH2_TERM_UNIT_CHARS
あるいは
SSH2_TERM_UNIT_PIXELS
のいずれかです。
成功時にストリームを返し、失敗した場合に false
を返します。
例1 コマンドの実行
<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$stream = ssh2_exec($connection, '/usr/local/bin/php -i');
?>