【问题标题】:ssh2_scp_send okay for first time but fail the second timessh2_scp_send 第一次没问题,第二次失败
【发布时间】:2013-12-13 22:04:02
【问题描述】:

我正在使用 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(): 在 /var/www/trunk/rsetting/class/ssh.class.php 第 57 行复制文件失败”

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

【问题讨论】:

  • 因为你在第一次传输后关闭了连接..ssh2_exec($this->conn, 'exit');
  • 感谢您的评论,我已删除该代码,但问题仍然存在 :(
  • 是的,完全一样的错误

标签: php ssh scp


【解决方案1】:

将 php-ssh2 扩展更新到 0.13 就可以了。

【讨论】:

    【解决方案2】:

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

    ssh2_exec($conn, 'exit');

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

    【讨论】:

      猜你喜欢
      • 2016-02-29
      • 1970-01-01
      • 2011-11-24
      • 2013-12-17
      • 2020-10-02
      • 2011-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多