FastCGI shell 脚本
我想将 FastCGI 与 shell 脚本一起使用。 我找到了几个关于在 shell 中编写 CGI 脚本的教程,但没有任何关于 FastCGI 的教程,我猜这不是一回事。
这可能吗?如何实现?
谢谢
编辑: Ignacio:谢谢,但此链接已有 14 年历史,并且表示当前不支持此功能。仍然不支持吗?
I would like to use FastCGI with shell scripts.
I have found several tutorials about writing CGI scripts in shell, but nothing about FastCGI, and I guess this is not the same thing.
Is it possible, and how?
Thank you
Edit: Ignacio: Thank you but this link is 14 years old and says that this is not currently supported. Is it still unsupported?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
FastCGI 的重点是避免为每个传入连接生成一个新进程。由于该语言的本质,shell 脚本在执行过程中会产生许多进程,除非您想极大地限制自己。 (没有
cat
、awk
、sed
、grep
等)。因此,从一开始,如果您要使用 shellscript,您不妨使用常规 CGI 而不是 FastCGI。如果您无论如何都下定决心,那么第一个大障碍是您必须在由网络服务器提供的侦听套接字上
accept()
连接。据我所知,没有 UNIX 工具可以做到这一点。现在,您可以用其他语言编写一个脚本,它可以为每个传入连接运行一次 shell 脚本。但这正是普通 CGI 所做的事情,而且我保证它比您或我编写的自定义程序更好。再次强调,如果您想使用 shellscript,请坚持使用普通的 CGI。The whole point of FastCGI is to avoid spawning a new process for each incoming connection. By the very nature of the language, a shell script will spawn many processes during its execution, unless you want to restrict yourself greatly. (No
cat
,awk
,sed
,grep
, etc, etc). So from the start, if you're going to use shellscript, you may as well use regular CGI instead of FastCGI.If you're determined anyway, the first big hurdle is that you have to
accept()
connections on a listening socket provided by the webserver. As far as I know, there is no UNIX tool that does this. Now, you could write one in some other language, and it could run your shellscript once for each incoming connection. But this is exactly what normal CGI does, and I guarantee it does it better than the custom program you or I would write. So again, stick with normal CGI if you want to use shellscript.“如果你无论如何都下定决心,第一个大障碍是你必须在网络服务器提供的侦听套接字上接受accept()连接。据我所知,(...)”有一个C程序几乎做了这个: exec_with_piped.c
(它使用管道,而不是套接字,但 C 代码应该很容易适应您的目的)
查看“在 sh 中编写代理:通过管道进行对话”
http://okmij.org/ftp/Communications.html
卡劳
"If you're determined anyway, the first big hurdle is that you have to accept() connections on a listening socket provided by the webserver. As far as I know, (...)" there is one C program doing nearly this: exec_with_piped.c
(it's using pipes, not sockets, but the C code should be easily adapted for your purpose)
Look at "Writing agents in sh: conversing through a pipe"
http://okmij.org/ftp/Communications.html
Kalou
否
No
来自 http://www.fastcgi.com/:
还:
因此,您可以将 FastCGI 与 shell 脚本或任何其他类型的脚本一起使用,就像 CGI 一样。
CGI 教程对于学习 FastCGI 也很有用,除了设置 Web 服务器的特殊性之外。
From http://www.fastcgi.com/:
Also:
So you can use FastCGI with shell scripts or any other kind of scripts, just like CGI.
Tutorials for CGI are useful to learn FastCGI too, except maybe for the particularities of setting up the web server.