我想使用像here这样的功能。请检查代码下面的代码stream_context_set_params不适用于ssh2.sftp包装
function notify (
$notification_code,
$severity,
$message,
$message_code,
$bytes_transferred,
$bytes_max
) {
echo "Runned \n";
};
$ctx = stream_context_create();
stream_set_params($ctx, array('notification' => 'notify'));
$ssh_connection = ssh2_connect('myhost');
ssh2_auth_password($ssh_connection, 'login','pass');
$sftp_resource = ssh2_sftp($ssh_connection);
$data = file_get_contents("ssh2.sftp://{$sftp_resource}/path/to/big/file",
false, $ctx);
我希望我的通知函数至少会被调用一次。 事实上,同样的代码适用于FTP包装
function notify (
$notification_code,
$severity,
$message,
$message_code,
$bytes_transferred,
$bytes_max
) {
echo "Runned \n";
};
$ctx = stream_context_create();
stream_set_params($ctx, array('notification' => 'notify'));
$scheme = 'ftp';
$data = file_get_contents("{scheme}://username:[email protected]:port/path/to/file",
false, $ctx);
,它工作正常!通知功能被多次调用。 我尝试使用SFTP包装这样
$data = file_get_contents("ssh2.sftp://username:[email protected]:port/path/to/big/file",
false, $ctx);
它isn`t工作过。 任何想法?
我不知道,但我想这也是SSH的概念之一。加密连接处理由ssh lib完成,而不是由php完成。因此没有通知。将调查,如果这是真的 – hek2mgl 2013-02-12 11:59:03
是的。似乎它不应该为ssh和ssh包装(scp,tunnel,sftp等)工作 – Stanislav 2013-02-12 12:38:44
是的。我也测试过了。顺便说一句,我在php-ssh2扩展中发现了一个段错误。 :| ...我目前正在查看扩展代码,以了解为什么不会调用通知。要么是通过设计,要么就是没有实施 – hek2mgl 2013-02-12 12:41:02