免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2251 | 回复: 6
打印 上一主题 下一主题

这个CGI程序是怎么回事? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-06-05 21:31 |只看该作者 |倒序浏览
#!/usr/bin/perl
use strict;
use warnings;
use CGI::Thin;
use CGI::Carp qw(fatalsToBrowser);
use HTML::Entities;

my $out_dir="/tmp";    #我不知道这里该用什么??windows下不是用\作分 # 隔符的吗?
sub debug()
{
   print "<H1>;DEBUG INFORMATION</H1>;\n";
   print "<H2>;Form  INformation</H2>;\n";

   my %form_info=Parse_CGI();
   foreach my $cur_key ( sort keys %form_info)
   {
     print "
;";
     if (ref $form_info{$cur_key})
     {
     foreach my $value (@{$form_info{$cur_key}})
     {
       print encode_entities($cur_key),"=",
             encode_entities($value),"\n";
     }
     } else
         {
         print encode_entities($cur_key),"=",
               encode_entities($form_info{$cur_key}),"\n";
         }
   }

   print "<H2>;Enviroment</H2>;\n";
   foreach my $cur_key ( sort keys %ENV)
   {
   print "
;";
   print encode_entities($cur_key),"=",
         encode_entities($ENV{$cur_key}),"\n";
   }
}
sub write_report()
{
   my %form_info=Parse_CGI();
   my $time=time();
   open OUT_FILE,">;$out_dir/form.$time" or
     die "could not open $out_dir/form.$time";

     print OUT_FILE "Nameform_info{name}
                     Group: $form_info{group}\n";
     if ($form_info{work})
     {
     print OUT_FILE "Full Time Employee\n";
     }
     if ($form_info{intern})
     {
      print OUT_FILE "art of the Intern program\n";
     }
     if (not defined ($form_info{schedule}))
     {
     print OUT_FILE "***Did not select a schedule\n";
     } else {
      print OUT_FILE "Scheduleform_info{schedule}\n";
      }
      print OUT_FILE "Comments:\n";
      print OUT_FILE "$form_info{comments}\n";
      close OUT_FILE ;
}

print "Content-type:text/html\n\n";

debug();
write_report();
print <<EOF;
<H1>;Thanks</H1>;
<p>;
Thank you for your time.
EOF
我用OptiPerl4.3它给出的提示是:
OptiPerl Server Warning
This script does not output it's mime type. It does not print something like:
print "Content-type: text/html\n\n";
The way this script output's it's header will not work on a real server! Here is the complete header:

[Sun Jun 5 21:13:21 2005] survey.pl: could not open /tmp/form.1117977201 at D:\Program Files\OptiPerl\Webroot\cgi-bin\survey.pl line 45.
Content-type:text/html
可是我看了后,还是不明白,求高手指点.
这是那个网页:
<head>;
    <title>;Survey</title>;
</head>;
<body>;
  <center>;<h1>lease fill in our survey</h1>;</center>;
<form  action="/cgi-bin/survey.pl"  method="post">;
<p>;
Name:
<input  type="text" NAME="name"  size=30>;

;
Group:
<Select NAME="group"  Size=1>;
     <option>;Software</option>;
     <option>;Marketing</option>;
     <option>;Support</option>;
</select>;

;
   <input type="checkbox" name="work" value="1"   checked>;
Full time employee
   </input>;

;
  <input  type="checkbox" name="intern" value="1">;
     Current a member of an intern program
  </input>;

;
<p>;
  I believe that my current project will be completed:

;
<INPUT type="radio" name="schedule" value="early">;
  Early
</input>;
<input type="radio"  name="schedule" value="ontime">;
On time
</input>;
<p>;
comments:

;
<textarea name="comments" cols=35 rows=4>;
Replace this with your comments.
</textarea>;
<input type="hidden" name="version" value="1.0">;

;
<input type="submit" value="Submit Form">;
</form>;
</body>;
</html>;

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
2 [报告]
发表于 2005-06-06 09:26 |只看该作者

这个CGI程序是怎么回事?

谁告你它是在 windows 下运行的?

论坛徽章:
0
3 [报告]
发表于 2005-06-06 20:03 |只看该作者

这个CGI程序是怎么回事?

不是在windows下运行的??
能仔细说说吗?我是个小菜鸟.

论坛徽章:
0
4 [报告]
发表于 2005-06-07 01:07 |只看该作者

这个CGI程序是怎么回事?

#!/usr/bin/perl

论坛徽章:
0
5 [报告]
发表于 2005-06-07 22:15 |只看该作者

这个CGI程序是怎么回事?

光从那个BANG行也不能说明就得在*INUX下用呀,我以前的那些在windows下也可用的.
     求高手帮帮忙啊.

论坛徽章:
0
6 [报告]
发表于 2005-06-08 08:00 |只看该作者

这个CGI程序是怎么回事?

设为"D:\tmp"试试,并确保其存在。

论坛徽章:
0
7 [报告]
发表于 2005-06-08 12:58 |只看该作者

这个CGI程序是怎么回事?

我这样也试了,可是还不行?
怎么总是说,没有MIME头呢?可是我确实是写了呀?
谁能告诉我这是为什么?
谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP