服务器语言执行shell 输出同步

s_wenze 2014-12-05 12:28:07
想用服务端语言执行shell脚本,php,jsp,node之类的,一般情况下这些语言获取shell输出结果都是整个shell执行完才能输出。
现在想做的是shell的输出同步,例如执行find / -name "*.conf" 后shell输出一行,node也能马上输出一行
...全文
199 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 3 楼 zhouqinghe24 的回复:
[quote=引用 2 楼 micropentium6 的回复:] [quote=引用 1 楼 zhouqinghe24 的回复:] 你可以将 执行结果的STDOUT_FILENO重定向(dup2)到你需要读取的文件描述符上。
I don't think the it will work. She'll works that way because the FILE stream stdout is line buffered since it is with terminal. Simply cloning file no. through dup2 will not change the behavior of buffering on the stream.[/quote] 你说的是对的。 但是你没有办法改变 已有软件的输出缓存机制 了 ,so 这个问题 没有答案。 [/quote] yes or no, we have no idea what the source looks like. say, popen is used, then you will have a file no. Can we change the default buffer behavior from full buffer to line buffer using setbuf against this file stream?
瑞卡哥哥 2014-12-09
  • 打赏
  • 举报
回复
引用 2 楼 micropentium6 的回复:
[quote=引用 1 楼 zhouqinghe24 的回复:] 你可以将 执行结果的STDOUT_FILENO重定向(dup2)到你需要读取的文件描述符上。
I don't think the it will work. She'll works that way because the FILE stream stdout is line buffered since it is with terminal. Simply cloning file no. through dup2 will not change the behavior of buffering on the stream.[/quote] 你说的是对的。 但是你没有办法改变 已有软件的输出缓存机制 了 ,so 这个问题 没有答案。
  • 打赏
  • 举报
回复
引用 1 楼 zhouqinghe24 的回复:
你可以将 执行结果的STDOUT_FILENO重定向(dup2)到你需要读取的文件描述符上。
I don't think the it will work. She'll works that way because the FILE stream stdout is line buffered since it is with terminal. Simply cloning file no. through dup2 will not change the behavior of buffering on the stream.
瑞卡哥哥 2014-12-07
  • 打赏
  • 举报
回复
你可以将 执行结果的STDOUT_FILENO重定向(dup2)到你需要读取的文件描述符上。

23,217

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧