我真的不知道如何运行Perl文件.我已将我的.pl上传到cgi-bin然后chmod到755.然后,当我去运行该文件时,我只得到500内部服务器错误.
**/cgi-bin/helloworld.pl**
#!/usr/bin/perl
print 'hello world';
Run Code Online (Sandbox Code Playgroud)
关于我做错了什么的任何想法?
当我尝试运行我的Perl CGI程序时,返回的网页告诉我:
软件错误:如需帮助,请发送邮件给网站管理员(root @ localhost),提供此错误消息以及错误的时间和日期.
这是我在其中一个文件中的代码:
#!/usr/bin/perl
use lib "/home/ecoopr/ecoopr.com/CPAN";
use CGI;
use CGI::FormBuilder;
use CGI::Session;
use CGI::Carp (fatalsToBrowser);
use CGI::Session;
use HTML::Template;
use MIME::Base64 ();
use strict;
require "./db_lib.pl";
require "./config.pl";
my $query = CGI->new;
my $url = $query->url();
my $hostname = $query->url(-base => 1);
my $login_url = $hostname . '/login.pl';
my $redir_url = $login_url . '?d=' . $url;
my $domain_name = get_domain_name();
my $helpful_msg = $query->param('m');
my $new_trusted_user_fname = $query->param('u');
my $action = …Run Code Online (Sandbox Code Playgroud) 我是Perl和复杂正则表达式的新手.我的意思是我之前使用过正则表达式的*,但没有比这更复杂.在下面的脚本中,我知道有一个非常大的安全漏洞,可以在其中注入和运行perl代码,以便即使是shell也可以执行任何命令.在试图阻止这种注射时,我逐渐意识到正则表达式比我想象的要困难得多.我正在使用的书说要使用它的组合
die "The specified user contains illegal characters!"
unless($user =~/^\w+$/);
Run Code Online (Sandbox Code Playgroud)
我相当肯定这意味着来自用户的输入必须以多个单词开头,但我不确定这是如何阻止注入命令的,因为它从不检查分号.我认为除非条款应该更像
unless($user=~/^\w+;\w$/);
Run Code Online (Sandbox Code Playgroud)
但是,似乎都不起作用.对此的任何帮助都会很棒,因为我真的很想理解这一点.谢谢!
#!/usr/bin/perl
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$q = new CGI;
print $q->header,
$q->start_html('Finger User'),
$q->h1('Finger User'),
print "<pre>";
$user = $q->param("user");
#die "the specified user contains illegal characters!"
# unless ($user =~ /ls/);
if (!($user =~ /^\w*;\w*$/)){
print `/usr/bin/finger -s $user`;
}
print "</pre>";
print $q->end_html;
Run Code Online (Sandbox Code Playgroud) 运行perl脚本时出现内部服务器错误.我将文件放入cgi-bin文件夹并设置权限755.请让我知道如何解决此问题?
cgi-bin文件夹中有两个文件.一个是perldigger.cgi.它的工作正常,其网址是http://mts.marketsignalsoftware.com/cgi-bin/perldigger.cgi,第二个是test.cgi.它给出了内部错误.我在其中编写了简单的代码,url是http://mts.marketsignalsoftware.com/cgi-bin/test.cgi.
#!/usr/bin/perl -w
# Program to do the obvious
print 'Hello world.';
# Print a message
Run Code Online (Sandbox Code Playgroud)
谢谢
所以我正在使用Windows 7和Xampp运行localhost测试服务器.我正在开发一个可以抓取网页的网页抓取工具,但是当我在浏览器中打开它时,我得到了脚本标头过早结束的错误.我以为我得到的不包括"打印"内容类型:text/html \n \n";" 这通常是问题..但事实并非如此.
这是我正在使用的代码:
#!"\xampp\perl\bin\perl.exe"
print "Content-Type: text/html\n\n";
use strict;
use warnings;
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use HTML::LinkExtor;
open my $file1,"+>>", ("links.txt");
select($file1);
my @urls = ('http://www.youtube.com/');
my $browser = LWP::UserAgent->new('IE 6');
$browser->timeout(10);
while (@urls) {
my $url = shift @urls;
my $request = HTTP::Request->new(GET => $URL);
my $response = $browser->request($request);
if ($response->is_error()) {printf "%s\n", $response->status_line;}
my $contents = $response->content();
my ($page_parser) = HTML::LinkExtor->new(undef, $url);
$page_parser->parse($contents)->eof;
@links = $page_parser->links;
foreach $link (@links) {
push …Run Code Online (Sandbox Code Playgroud) 我收到错误"内部服务器错误.服务器遇到内部错误或配置错误,无法完成您的请求."
我在html中提交表单并获取其值.
HTML代码(index.cgi)
#!c:/perl/bin/perl.exe
print "Content-type: text/html; charset=iso-8859-1\n\n";
print "<html>";
print "<body>";
print "<form name = 'login' method = 'get' action = '/cgi-bin/login.pl'> <input type = 'text' name = 'uid'><br /><input type = 'text' name = 'pass'><br /><input type = 'submit'>";
print "</body>";
print "</html>";
Run Code Online (Sandbox Code Playgroud)
用于获取数据的Perl代码(login.pl)
#!c:/perl/bin/perl.exe
use CGI::Carp qw(fatalsToBrowser);
my(%frmfields);
getdata(\%frmfields);
sub getdata {
my ($buffer) = "";
if (($ENV{'REQUEST_METHOD'} eq 'GET')) {
my (%hashref) = shift;
$buffer = $ENV{'QUERY_STRING'};
foreach (split(/&/,$buffer)) {
my ($key, $value) = split(/=/, $_); …Run Code Online (Sandbox Code Playgroud)