欺骗计划和CGI?

发布于 2024-09-15 03:09:36 字数 941 浏览 4 评论 0原文

我最近发现 CGI 脚本几乎可以用任何可以打印到标准输出的语言编写。我写了一个小的 guile cgi 脚本,它适用于我的本地 apache 安装,但不适用于我的共享主机:

#!/usr/local/bin/guile -s 
!#
(display "Content-Type: text/html")
(newline)
(newline)
(display "hi")
(newline)

这是当我通过 ssh 从主机上的 shell 运行该脚本时的输出:

$ ./scheme.cgi
Content-Type: text/html

hi

所以,显然我的主机有 guile安装。但是,当我尝试在浏览器中访问此文件时,收到“500 内部服务器错误”。当查看我的错误日志时,我发现我收到了可怕的“脚本头过早结束”错误:

[server.com] [Tue Aug 17 00:54:19 2010] [error] [client xx.xx.xx.xxx] (2)No such file or directory:
exec of '/home/www/vhosts/jcw.geekisp.com/cgi-bin/scheme.cgi' failed

[server.com] [Tue Aug 17 00:54:19 2010] [error] [client xx.xx.xx.xxx] Premature end 
of script headers: scheme.cgi

因为我位于共享主机上,所以不可能使用 mod_lisp 或 guile 的 fastcgi 实现。话虽如此,这里可能存在什么问题?我用 python、perl、ruby 和 sh 编写的类似 cgi 脚本在服务器上运行没有错误。我看到主机上安装了 guile 1.8.7,但我的本地计算机是最新版本。

我知道这是一个非常小众的问题,任何帮助将不胜感激!

I recently discovered that CGI scripts can be written in pretty much any language that can print to stdout. I've written a small guile cgi script that works on my local apache install, but not on my shared host:

#!/usr/local/bin/guile -s 
!#
(display "Content-Type: text/html")
(newline)
(newline)
(display "hi")
(newline)

This is the output, when I run the script from a shell on my host over ssh:

$ ./scheme.cgi
Content-Type: text/html

hi

So, obviously my host has guile installed. However, when I try to access this file in a browser, I get a "500 Internal Server Error". When looking at my error logs, I see that I am getting the dreaded "premature end of script headers" error:

[server.com] [Tue Aug 17 00:54:19 2010] [error] [client xx.xx.xx.xxx] (2)No such file or directory:
exec of '/home/www/vhosts/jcw.geekisp.com/cgi-bin/scheme.cgi' failed

[server.com] [Tue Aug 17 00:54:19 2010] [error] [client xx.xx.xx.xxx] Premature end 
of script headers: scheme.cgi

Because I am on a shared host, using mod_lisp or guile's fastcgi implementation are out of the question. That being said, what could be the issue here? Similar cgi scripts I've written in python, perl, ruby, and sh work on the server with no errors. I see that guile 1.8.7 is installed on the host, but my local machine is on the newest version.

I understand that this is an incredibly niche question, any help would be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

弄潮 2024-09-22 03:09:36

您也许还可以编译您自己的 guile 副本或诸如此类的东西,并将其存储在您的 ~/bin/ 目录中,并将脚本指向那里。

You might also be able to compile your own copy of guile or whatnot and store it in your ~/bin/ directory and have scripts point there.

并安 2024-09-22 03:09:36

我相信该错误意味着您的 Web 服务器进程无权访问 /usr/local/bin/guile 解释器。检查该文件的权限,确保服务器在 chroot 中运行或在强制访问控制下等情况下可以访问该文件。并在执行脚本时仔细检查脚本的权限。

I believe that error means your web server process doesn't have access to the /usr/local/bin/guile interpreter. Check the permissions on that file, make sure it is accessible if the server runs in a chroot or under mandatory access control, etc. And double-check the permissions on your script while you're at it.

不乱于心 2024-09-22 03:09:36

事实证明,当我在服务器上进行 ssh 时存在的 /usr/local/bin 目录与通过浏览器提供和访问脚本时的 /usr/local/bin 目录不同。我发现通过这个 CGI 脚本可以使用哪些解释器:

#!/bin/sh
echo "Content type: text/html\r\n\r\n"
echo "ls /usr/local/bin"

当我通过浏览器运行这个脚本时,我发现列出了 mzscheme,但没有列出 guile。所以,问题解决了,我正在使用 mzscheme。

谢谢,卡尔。

It turns out that, the /usr/local/bin directory that exists when I'm ssh'ed on the server is different from the /usr/local/bin when the script is served and accessed through a browser. I found out what interpreters were available through this CGI script:

#!/bin/sh
echo "Content type: text/html\r\n\r\n"
echo "ls /usr/local/bin"

When I ran this script through a browser, I found that mzscheme was listed, but not guile. So, problem solved, I'm using mzscheme.

Thanks, Karl.

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