FastCGI shell 脚本

发布于 2024-10-11 21:49:29 字数 208 浏览 1 评论 0原文

我想将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

半世晨晓 2024-10-18 21:49:29

FastCGI 的重点是避免为每个传入连接生成一个新进程。由于该语言的本质,shell 脚本在执行过程中会产生许多进程,除非您想极大地限制自己。 (没有 catawksedgrep 等)。因此,从一开始,如果您要使用 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.

滿滿的愛 2024-10-18 21:49:29

“如果你无论如何都下定决心,第一个大障碍是你必须在网络服务器提供的侦听套接字上接受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

挽容 2024-10-18 21:49:29

<块引用>

如果这是一个愚蠢的问题,我提前道歉,但这是吗?
可以想象使用纯粹的 shell 脚本(sh 或 ksh)作为
FastCGI 程序,如果可以,怎么样?

您不能使用简单的 shell 脚本作为 FastCGI 程序。自从
shell脚本不能跨多个HTTP请求持久化,它不能
用作 FastCGI 应用程序。让程序能够处理多个HTTP
请求在其自己的生命周期内(即不只是处理请求然后死亡,就像
CGI应用程序),它需要一些手段与Web服务器进行通信
接收请求,处理后将回复发送回服务器
它。这种通信是通过 FCGI 库完成的,该库实现了
上述内容目前仅支持一部分编程语言,
像C、Perl、Tcl、Java...总之,它不支持shell。
希望这能澄清一点。
斯坦利。

No

I apologize in advance if this is a dumb question but is it
conceivable to use a mere shell script (sh or ksh) as a
FastCGI program and if so, how?

You can not use a simple shell script as a FastCGI program. Since
shell script can not persist across multiple HTTP requests, it can not be
used as a FastCGI application. For the program to handle multiple HTTP
requests in its own lifetime (i.e. not just handle requests and die, like
CGI applications), it needs some means to communicate with the web server
to recieve a request, and send the reply back to the server after handling
it. This communication is accomplished via FCGI library, which implements
the above and it currently supports only a subset of programming languages,
like C, Perl, Tcl, Java... In short, it does NOT support shell.
Hope that cleared it up a bit.
Stanley.

写下不归期 2024-10-18 21:49:29

来自 http://www.fastcgi.com/

FastCGI 很简单,因为它实际上是只有几个扩展的 CGI。

还:

与 CGI 一样,FastCGI 也是与语言无关的。

因此,您可以将 FastCGI 与 shell 脚本或任何其他类型的脚本一起使用,就像 CGI 一样。

CGI 教程对于学习 FastCGI 也很有用,除了设置 Web 服务器的特殊性之外。

From http://www.fastcgi.com/:

FastCGI is simple because it is actually CGI with only a few extensions.

Also:

Like CGI, FastCGI is also language-independent.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文