ssh2_scp_send第一次正常,但第二次失败


ssh2_scp_send okay for first time but fail the second time

我正在使用php ssh2_scp_send将文件传输到远程机器,但这有点奇怪,它第一次工作,但第二次调用失败,出现以下错误

//success for file transfer
if (!(ssh2_scp_send($this->conn, $lpath, $rpath, 0777))){
            throw new Exception("File transfer failed!");
        }
        ssh2_exec($this->conn, 'exit'); 
//fail this time
if (!(ssh2_scp_send($this->conn, $lpath, $rpath, 0777))){
            throw new Exception("File transfer failed!");
        }
        ssh2_exec($this->conn, 'exit')

"警告:ssh2_scp_send():在第57行的/var/www/trunk/rsetting/class/ssh.class.php中复制文件失败"

任何帮助都将不胜感激~感谢

将php-ssh2扩展名更新为0.13即可。

我遇到了同样的问题,但通过调用以下函数解决了它:

ssh2_exec($conn, 'exit');

在循环结束时。我认为这个命令会刷新缓冲区并正确写入最后一个远程文件。