douliang9057 2011-06-30 07:37
浏览 83

PHP CLI记录交互式SSH会话的输出

I've been trying to sort out recording an interactive SSH session via a PHP CLI script. All I really want is sort of like a tee command, where the entire output is recorded into a string.

I've tried most of the commands to execute external processes to get it to work. They either work ok such as passthru and pcntl_exec but don't let me record the output into a string or array, or they don't display any output to my terminal but still accept stuff from STDIN.

I'm wondering if there is a way of having an interactive ssh session i.e, works normally, but actually records the output for use in PHP.

Thanks

  • 写回答

3条回答 默认 最新

  • dosgy00204 2011-06-30 08:16
    关注

    They either work ok such as passthru and pcntl_exec but don't let me record the output into a string or array

    Well, you can use a hack to get that string:

    ob_start();
    passthru('Your command here');
    $result=ob_get_clean();
    

    It is bad, but if your server is not high-load - it should work.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法