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.

    评论

报告相同问题?

悬赏问题

  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿