简体   繁体   English

如何在执行cgi时使apache跳过特定的stdout行或停止从打印到stdout的共享库

[英]How to make apache skip specific stdout lines when executing cgi or stop shared library from printing to stdout

My apache server executes a cgi bin and reads the lines outputted to stdout. 我的apache服务器执行一个cgi bin并读取输出到stdout的行。 The thing is, every time the cgi-bin is executed some lines due to the API dynamic library loading are present. 问题是,每次执行cgi-bin时都会由于API动态库加载而出现一些行。 Apache can't distinguish now those 3 lines from HTTP requests to initiate my streaming. Apache现在无法从HTTP请求中区分出这3行来启动我的流式传输。 There is a way to make apache skip the lines that are keeping it from working or to stop the shared libraries from printing its loads? 有一种方法可以使apache跳过保持其正常运行的行,或者使共享库停止打印其负载?

If your site is doing fewer than a couple of requests per second, you can use a simple hack by wrapping your CGI with a shell script that will filter out the problem lines: 如果您的站点每秒执行的请求少于几个,则可以通过将CGI包装到可以过滤问题行的shell脚本中来使用简单的技巧:

-- put the code below in your new cgi script and make sure to chmod +x -- test by running it manually in the shell -- -将以下代码放入新的cgi脚本中,并确保使用chmod +x –通过在外壳中手动运行进行测试–

#! /bin/bash
/path/to/old-cgi | egrep -v troublestring1\|troublestring2\|troublestring3 

You must make sure that the trouble strings are unique enough to never legitimately appear in your real output. 您必须确保故障字符串的唯一性足以确保其合法输出永远不会合法出现。 If you you cannot find such strings, you may need a more sophisticated parsing script in place of egrep filter. 如果找不到这样的字符串,则可能需要更复杂的解析脚本来代替egrep过滤器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM