doutuo3935 2014-10-21 21:24
浏览 57

Phpseclib:部分文件下载

What is the best way (using phpseclib) to download a partial file. I have a log file where data is constantly appended. I would like to periodically connect to a remote server and download the latest chunk without downloading the whole file every time. Rsync would be perfect but its not installed on every server. I'm currently able to do it using a number of commands where I would record the last line number, than use tail (with last line number) and pipe it to a tmp file. SCP the tmp file to my local machine and than delete the tmp file.

However, this method is too complicated and intrusive (requires creating/deleting a file on a remote machine). Also, I can not install anything on the remote machine and they might be different (bsd, linux, solaris, etc).

  • 写回答

1条回答 默认 最新

  • dongshuo9350 2014-10-21 22:00
    关注

    The function definition for Net_SFTP::get is as follows:

    function get($remote_file, $local_file = false, $offset = 0, $length = -1)
    

    So maybe you could do $sftp->get('/path/to/file.log', false, $last_recorded_size) or something.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100