不带服务器运行cgi程序

时间:2011-04-03 11:58:55

标签: testing cgi

是否有一个给出cgi程序的工具,并且参数(查询字符串,方法,要上传的文件等)将设置正确的环境变量,并执行此程序(带或不带调试器)

类似于这个perl脚本,只有更加可靠,输出和输入更清晰,支持文件等。

1 个答案:

答案 0 :(得分:0)

嗯,这个问题诞生了一个新的开源项目。我正在复制here的答案。

如果你只是想看看你的CGI正在运行,你可以使用我的小runCGI项目。

您只需要设置一个类似于此内容的yaml文件

_exec: /var/cgi-bin/myfile.cgi
method: GET
query_string:
  q: s

然后运行

./runCGI myyamlfile.yaml

您将在控制台的标准输出上看到输出。

您甚至可以使用gdb调试它,调试runCGI gdb runCGI,使用正确的参数(run someyaml.yaml)运行,发现tcatch exectcatch抓住它只有一次)然后设置断点到您的CGI文件:

$ g++ a.cc -o a.out
$ cat a.yaml
method: GET
_exec: a.out
$ gdb runCGI
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(gdb) tcatch exec
Catchpoint 1 (exec)
(gdb) run a.yaml
Starting program: /home/elazar/runCGI/runCGI a.yaml
Executing new program: /home/elazar/runCGI/a.out
0x00007fc3a24a6a60 in ?? () from /lib64/ld-linux-x86-64.so.2
(gdb) tbreak main
Breakpoint 2 at 0x400577: file a.cc, line 2.
(gdb) c
Continuing.
main (argc=1, argv=0x7fff14891408) at a.cc:2
2       int a =0;
(gdb)