doudu2404
2013-11-28 01:59 阅读 319

ssh2_scp_send第一次没问题,但第二次失败了

I am making use of php ssh2_scp_send to transfer files to the remote machine, but it is a bit weird, it works for the first time but fails my second call with the following error

//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')

"Warning: ssh2_scp_send(): Failed copying file in /var/www/trunk/rsetting/class/ssh.class.php on line 57"

Any help will be appreciated~Thanks

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • dongmangsha7354 dongmangsha7354 2016-06-28 02:58

    update php-ssh2 extension to 0.13 will be fine.

    点赞 评论 复制链接分享
  • dping1968 dping1968 2017-05-30 10:51

    I had the same problem but solved it by calling this function:

    ssh2_exec($conn, 'exit');

    at the end of the loop. I think this command flush the buffer and write correctly the last remote file.

    点赞 评论 复制链接分享

相关推荐